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

switch http client to something that does not have a native extension #237

Open
grosser opened this issue Mar 15, 2017 · 11 comments
Open

switch http client to something that does not have a native extension #237

grosser opened this issue Mar 15, 2017 · 11 comments
Labels
enhancement watches About watching k8s objects

Comments

@grosser
Copy link
Contributor

grosser commented Mar 15, 2017

faraday or httparty would come to my mind ...

 gem i rest-client
Fetching: unf_ext-0.0.7.2.gem (100%)
Building native extensions.  This could take a while...
Successfully installed unf_ext-0.0.7.2
Fetching: unf-0.1.4.gem (100%)
Successfully installed unf-0.1.4
Fetching: domain_name-0.5.20170223.gem (100%)
Successfully installed domain_name-0.5.20170223
Fetching: http-cookie-1.0.3.gem (100%)
Successfully installed http-cookie-1.0.3
Fetching: mime-types-data-3.2016.0521.gem (100%)
Successfully installed mime-types-data-3.2016.0521
Fetching: mime-types-3.1.gem (100%)
Successfully installed mime-types-3.1
Fetching: netrc-0.11.0.gem (100%)
Successfully installed netrc-0.11.0
Fetching: rest-client-2.0.1.gem (100%)
Successfully installed rest-client-2.0.1
8 gems installed
@cben
Copy link
Collaborator

cben commented Mar 26, 2017

Oh, I thought Kubeclient is purely rest-client but turns out we also use http gem for WatchStream functionality.
And http also requires native extenstions via http-cookie < domain_name < unf < unf_ext (EDIT: not nokogiri that's, only for devel).

I propose any replacement should:

And old but detailed comparison: https://bibwild.wordpress.com/2012/04/30/ruby-http-performance-shootout-redux/
=> httpclient gem came on top there, pure ruby (zero deps 🥇), has persistent connections + thread safe. TOCHECK:

  • rerun those benchmarks, there is a newer fork but also needs some updating
  • does httpclient support GET streaming? get_content yields chunks of String, get_async returns HTTPClient::Connection — sounds good on paper.

https://jvns.ca/blog/2016/03/04/whats-up-with-ruby-http-libraries/ sumarises nahi's epic table https://bit.ly/RubyHTTPClients2012 (slides), with a crucial point that at the bottom everything builds on just 4 libs: Net:HTTP, Excon, httpclient and native libcurl.
IMHO adopting one well-designed lib sounds nicer than a stack of several...

Faraday is unusual in supporting many backend libs with same API.

  • Faraday can use Patron, a native libcurl binding. But it seems it doesn't automatically pull it in, so that's OK.
  • It seems streaming could only work with Net::HTTP, and hasn't landed yet: Streaming requests for Net::HTTP lostisland/faraday#604. Oh, @grosser you reviewed that — can you say if we'd need it to land before we could do watching?

@cben
Copy link
Collaborator

cben commented Mar 26, 2017

@grosser
Copy link
Contributor Author

grosser commented Mar 26, 2017 via email

@cben
Copy link
Collaborator

cben commented Apr 18, 2017

@msufa You'd switched watching to use http.rb for Celluloid support — can you comment whether any of the alternatives here (especially httpclient) could work for your needs?
(BTW, do you know if we still need http.rb pegged to 0.9.8? It's now at 2.2.1, with 3.x branch in the works. A dependency we can't upgrade is one more reason to consider a switch...)


Other requirements: #140 lists several.
I'd also like to understand where kubernetes API is going — protobuf?
HTTP/2? gRPC? @smarterclayton can you give us a hint what a k8s client lib should plan for?

@msufa
Copy link
Contributor

msufa commented Apr 19, 2017

@cben as noted in #204 (comment) Celluloid support should no longer be necessary, so you're free to go with whichever HTTP implementation you find works best for you :)

@moolitayer
Copy link
Collaborator

see #254

@cben
Copy link
Collaborator

cben commented Jul 5, 2017

We might also need websocket support at some point. No idea what means in terms of gems.

It seems from docs websockets are already supported for watches (don't know if it gives any benefit over GET), and looks like they'll be required for certain types of bulk watching: kubernetes/community#443

@grosser
Copy link
Contributor Author

grosser commented Aug 30, 2017

FYI faraday now has streaming lostisland/faraday#604

@cben
Copy link
Collaborator

cben commented Jun 14, 2020

Just a data point: replacing http and rest-client with httpclient would make the bundle way smaller: 34MB -> 5MB. It's now dominated by ffi and unf_ext.

@andrzej-stencel
Copy link
Contributor

Folks, here's draft PR (work in progress): #466 to give users the option to replace rest_client with httpclient with an initialization parameter like this:

client = Kubeclient::Client.new('https://apiserver/api', 'v1', http_client_type: 'httpclient')

I'd love to hear your thoughts on this.

@cben
Copy link
Collaborator

cben commented Nov 3, 2020

In case anyone here has opinions between Faraday / httpclient / another lib — NOW is your last chance to influence! 😉 Join #466 discussion ^^. Note that support for connection reuse is a must for @astencel-sumo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement watches About watching k8s objects
Projects
None yet
Development

No branches or pull requests

5 participants