Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose config option to keep alive TCP connections #351

Merged
merged 1 commit into from
Jul 3, 2024
Merged

Conversation

stmcginnis
Copy link
Owner

@stmcginnis stmcginnis commented Jul 2, 2024

This adds a ReuseConnections configuration flag. When set, this will try to configure the HTTPClient transport to not immediately close connections so that they can be reused by subsequent API calls.

Closes: #349

Testing

I ran something that collects a lot of different information from a system. Its original unmodified timing was:

real	0m35.706s
user	0m0.165s
sys	0m0.063s

After setting the new reuse flag, the same operations timing was:

real	0m26.284s
user	0m0.266s
sys	0m0.083s

I also tried tweaking both ReuseConnections: true and MaxConcurrentRequests: 2 and got even better results:

real	0m21.510s
user	0m0.092s
sys	0m0.039s

This adds a `ReuseConnections` configuration flag. When set, this will
try to configure the HTTPClient transport to not immediately close
connections so that they can be reused by subsequent API calls.

Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
@stmcginnis
Copy link
Owner Author

Local testing is good, so I'm going to merge this. But I would still appreciate any feedback from others to make sure this seems to work as expected and to know if there are any issues with this approach that I've overlooked. Please open an issue if there are any negative side effects from this that I've overlooked.

@stmcginnis stmcginnis merged commit 700a38e into main Jul 3, 2024
2 checks passed
@stmcginnis stmcginnis deleted the keep-alive branch July 3, 2024 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

http requests to keep using the same TCP connection
1 participant