-
Notifications
You must be signed in to change notification settings - Fork 898
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
Reuse persistent HTTP connections #13345
Comments
@cben 👍 , the ruby and python clients ask for the hawkular version each time they create a new connection object, and since we do not have a good way to reuse ( and stay updated, and not timeout, and ... ) the connection object is recreated almost(*) each new query. (*) we do try to reuse when we can, clients are usually global and created using |
(*) https://github.com/hawkular/hawkular-client-ruby/blob/02041e319eabc6851d0a5adf2319af3b83643ad9/lib/hawkular/base_client.rb#L40-L41 |
=> Refresh is much better than I feared :-). Not much point optimizing (until we get into targeted / watching refresh).
Tip: running under @yaacov when you have a chance doing metric collections / live metrics, do you mind setting RESTCLIENT_LOG and getting an idea how many requests total we do in that area? |
@cben 👍 p.s. |
This issue has been automatically marked as stale because it has not been updated for at least 6 months. If you can still reproduce this issue on the current release or on Thank you for all your contributions! |
@miq-bot move-issue manageiq-providers-kubernetes |
This issue has been moved to ManageIQ/manageiq-providers-kubernetes#124 |
I noticed recently we don't reuse HTTP connections. A new TCP/TLS/HTTP connection every request may add up to an order of magnitude speed difference:
https://bibwild.wordpress.com/2012/04/30/ruby-http-performance-shootout-redux/
HawkularClient creates a new RestClient instance for every single call.
Kubeclient does cache RestClient instance, but RestClient itself doesn't support connection reuse!
Connection reuse rest-client/rest-client#453
[?] Net::HTTP when used directly does support persistent connections in limited scenarios (passing a block to .start). I believe we use it through MiqFs for image scanning, not sure how exactly.
[?] @yaacov also told me one of the client libs (
maybe in python though?) does API discovery anew before every single action.P.S. new connections are probably more expensive when going through proxies, e.g. to hawkular running in a pod?
After some reading, for fresh developement, httpclient or excon could be better than restclient, on several aspects.
For our existing code, https://github.com/drbrain/net-http-persistent (co-authored by tenderlove :-) sounds a good start. I propose trying quick&dirty patch to use it in RestClient (and MiqFs), measuring how much we stand to gain, and working with RestClient to add at least opt-in option.
@miq-bot add-label providers/containers, providers/hawkular, performance
/cc @lucasponce
Probably happens with other providers, a quick search through Gemfile.lock shows only excon used by fog & OpenstackHandle, httpclient used by WinRm.
The text was updated successfully, but these errors were encountered: