Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Ruby HTTP clients

556 views

Published on

comparison of the most popular Ruby HTTP clients

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Ruby HTTP clients

  1. 1. Ruby HTTP clients Full Stack Landscape
  2. 2. Report by Hiroshi Nakamura http://bit.ly/RubyHTTPClients2012 http://jvns.ca/blog/2016/03/04/whats-up-with-ruby-http-libraries/
  3. 3. Taxonomy by Hiroshi Nakamura http://bit.ly/RubyHTTPClients2012
  4. 4. My Taxonomy • gems based on TCPSocket (a Ruby C library):
 Net::HTTP (built-in Ruby) , HTTPClient • gems based on eventmachine (C++ library):
 EM-HTTP-Request, Excon • 3 groups of "wrapper gems": • HTTParty, HTTP.rb, Rest-Client use Net::HTTP as "backend" • Typhoeus, Curb, Patron use libcurl (a C library) • Faraday have adapter for: Net::HTTP (default), HTTPClient, EM-HTTP-Request, Excon, Typhoeus, Patron
  5. 5. Avdi's Survey http://devblog.avdi.org/2015/10/16/results-of-ruby-http-client-library-survey/
  6. 6. Avdi's Survey (Top 10) • HTTParty "simplicity and ease of use" • Faraday "ability to modify its behavior with middlewares, swap backend libraries" • Net::HTTP "built-in, no extra dependency, robustness and stability" • Rest-Client “easy api, just works, can do file uploads” • HTTPClient “thread-safe, uses keepalive, fast, supports http streaming.” • Excon “easy to use, customize, easy to handle errors, has feature to debug” • HTTP.rb “thread safety (jRuby), a sane API for SSL (e.g. mutual auth)” • Typhoeus “concurrent requests and multipart posts actually work.” • Curb “benchmarks showed that curb is by far the fastest one.” • Patron “nicer API than Curb, easy to set timeout, easy to log and do REST actions.” http://devblog.avdi.org/2015/10/16/results-of-ruby-http-client-library-survey/
  7. 7. Popularity (Top 5) Survey Stars HTTParty 25.5% 3.569 Faraday 24.9% 3.027 Net::HTTP 12.7% - Rest-Client 10.9% 3.258 Typhoeus 6% 2.737 HTTPClient 5.2% 501 HTTP.rb 3.5% 1.206 Excon 3.3% 710 Curb 2.9% 945 Patron 0.9% 466
  8. 8. Samples for Top 5
  9. 9. HTTParty
  10. 10. Faraday
  11. 11. Faraday adapters Survey Stars HTTParty 25.5% 3.569 Faraday 24.9% 3.027 Net::HTTP 12.7% - Rest-Client 10.9% 3.258 Typhoeus 6% 2.737 HTTPClient 5.2% 501 HTTP.rb 3.5% 1.206 Excon 3.3% 710 Curb 2.9% 945 Patron 0.9% 466 em-http-request - 1.064
  12. 12. Rest-Client a simple DSL for accessing HTTP and REST resources
  13. 13. Typhoeus
  14. 14. Speed Test by @nahi
  15. 15. Speed Test by @nahi
  16. 16. Speed Test by @tarcieri https://github.com/httprb/http/blob/master/README.md
  17. 17. Net::HTTP implementation
  18. 18. The Simples HTTP Get require 'net/http'
 puts Net::HTTP.get('www.google.com', '/') "pure TCP socket" HTTP GET
 (without Net::HTTP)
 based on RFC 2616 https://gist.github.com/zmajstor/ 94b85c7821b129f71ad6 https://github.com/ruby/ruby/blob/ trunk/ext/socket/socket.c
  19. 19. TCPServer - TCPSocket https://gist.github.com/ zmajstor/ 94b85c7821b129f71ad6
  20. 20. The End

×