-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add optional Session to Service to be able to reuse connections (#1183)
**Pull Request Checklist** - [ ] Fixes #<!--issue number goes here--> - [x] Tests added - [ ] Documentation/examples added - [x] [Good commit messages](https://cbea.ms/git-commit/) and/or PR title **Description of PR** The WorkflowService uses direct calls to requests library, which under the hood creates a Session, makes the request, then closes the session. This means that the TCP connection is opened and closed for each call instead of being reused - which causes unnecessary overhead if the service is making multiple calls. This PR adds the possibility to use a Session object in the Service, by default not enabled to keep the current behavior as-is. From a performance point of view, if Argo is running locally the advantage will be virtually non-existent ; however, we can simulate the outcome with a remote Argo server using [toxiproxy](https://github.com/Shopify/toxiproxy/): ```bash toxiproxy-cli create --listen localhost:2747 --upstream localhost:2746 argo toxiproxy-cli toxic add -t latency -a latency=20 -a jitter=5 argo ``` Using ipython and the magic command %timeit: ``` from hera.workflows import WorkflowsService # default current behavior: no session ws = WorkflowsService("https://localhost:2747", verify_ssl=False) %timeit -n10 -r10 ws.list_workflows("argo") 133 ms ± 2.17 ms per loop (mean ± std. dev. of 10 runs, 10 loops each) ws = WorkflowsService("https://localhost:2747", verify_ssl=False, use_session=True) %timeit -n10 -r10 ws.list_workflows("argo") 77.4 ms ± 2.01 ms per loop (mean ± std. dev. of 10 runs, 10 loops each) ``` In toxiproxy logs (and the kubectl port-forward logs) , we can see that the tcp open is done now only once. Thanks! --------- Signed-off-by: Timothé Perez <achille.ash@gmail.com> Signed-off-by: Elliot Gunton <elliotgunton@gmail.com> Co-authored-by: Elliot Gunton <elliotgunton@gmail.com>
- Loading branch information
1 parent
1d8a17c
commit e09ce27
Showing
4 changed files
with
259 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.