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

Reuse persistent HTTP connections #124

Open
2 tasks
miq-bot opened this issue Oct 1, 2017 · 10 comments
Open
2 tasks

Reuse persistent HTTP connections #124

miq-bot opened this issue Oct 1, 2017 · 10 comments

Comments

@miq-bot
Copy link
Member

miq-bot commented Oct 1, 2017

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.

  • Further ahead, given connection reuse, could gain even more from HTTP/2, should keep it in mind when choosing gems.

@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.


This issue was moved to this repository from ManageIQ/manageiq#13345, originally opened by @cben

@cben
Copy link
Contributor

cben commented Oct 1, 2017

Summary from original issue + updates:

@yaacov told me it'd be possible to modify our metrics capture to do much fewer batch queries, both with hawkular and prometheus, potentially making this non-issue.

@miq-bot
Copy link
Member Author

miq-bot commented Oct 1, 2017

@miq-bot Cannot apply the following labels because they are not recognized: providers/containers, providers/hawkular

@miq-bot
Copy link
Member Author

miq-bot commented Oct 1, 2017

@miq-bot unrecognized command 'Cannot', ignoring...

Accepted commands are: add_label, assign, close_issue, move_issue, remove_label, rm_label, set_milestone

@yaacov
Copy link
Member

yaacov commented Oct 1, 2017

@yaacov told me it'd be possible to modify our metrics capture to do much fewer batch queries, both with hawkular and prometheus, potentially making this non-issue.

@cben , yes it's a POC planed by @agrare , It's on my todo list, didn't get to it yet :-(

@miq-bot miq-bot added the stale label Apr 2, 2018
@miq-bot
Copy link
Member Author

miq-bot commented Apr 2, 2018

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 master, please reply with all of the information you have about it in order to keep the issue open.

Thank you for all your contributions!

@gtanzillo
Copy link
Member

@cben Would you have an idea of the sizing of this issue? S / M / L / XL.

@miq-bot
Copy link
Member Author

miq-bot commented Feb 22, 2021

@miq-bot Cannot apply the following labels because they are not recognized:

  • providers/containers
  • providers/hawkular

All labels for ManageIQ/manageiq-providers-kubernetes: https://github.com/ManageIQ/manageiq-providers-kubernetes/labels

@miq-bot
Copy link
Member Author

miq-bot commented Feb 22, 2021

@miq-bot unrecognized command 'Cannot', ignoring...

Accepted commands are: add_label, add_reviewer, request_review, assign, close_issue, cross_repo_test, move_issue, remove_label, rm_label, remove_reviewer, set_milestone, unassign

NickLaMuro added a commit to NickLaMuro/miq_bot that referenced this issue Feb 22, 2021
Removes bot thinking it is calling itself when making a comment where
it's username could be used when adding a label.

See the following for an example:

  ManageIQ/manageiq-providers-kubernetes#124 (comment)
@cben
Copy link
Contributor

cben commented Feb 28, 2021

Kubeclient 4 used rest-client, which is no longer maintained, and doesn't support persistent connections: rest-client/rest-client#453

Kubeclient 5.0 will support this, at least partially.

  • Replace rest_client with faraday kubeclient#466 (merged to master) replaced rest-client (used for all requests except watch) with Faraday.
    This will allow client.faraday_client.adapter(:net_http_persistent) to reuse connections within a single Client object (manageiq needs several Client objects — one per api group).

  • Replace http gem with faraday kubeclient#488 will replace http gem (used for watch) with Faraday. This got stuck on how to implement .finish, need to decide how to proceed. However as a watch remains open it ties up 1 connection anyway, so this doesn't matter for connection reuse — it's just an open problem that has delayed progress towards release...

  • some more goals I hoped for 5.0 release, maybe not all blockers: 5.0 incompatible changes plan kubeclient#435

@miq-bot
Copy link
Member Author

miq-bot commented Feb 28, 2021

@miq-bot unrecognized command 'unrecognized', ignoring...

Accepted commands are: add_label, add_reviewer, request_review, assign, close_issue, cross_repo_test, move_issue, remove_label, rm_label, remove_reviewer, set_milestone, unassign

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Roadmap
  
Awaiting triage
Development

No branches or pull requests

5 participants