random Ruby http related gems:
- retriable
- hurley
- hurley excon adapter -- a curb adapter for hurley would be nice
- google's API client uses hurley
http_shooting_party is another benchmarking tool. Often curb is 8.42x
faster than excon in this benchmark.
Start a passenger server that serves test.json.
$ passenger
$ cat public/test.json
{"foo":"bar"}
Invoke the benchmark gem once for each backend. Make sure to install the gems before running the benchmark.
$ nano lib/http_shooting_party/test.rb # edit UNDER_TEST.new to use http://0.0.0.0:3000/test.json
$ gem build http_shooting_party.gemspec
$ gem install --local http_shooting_party-0.0.1.gem
$ pry
%w(curb excon fake httpparty httpclient net_http patron typhoeus).each { |a| `http_shooting_party #{a}` }
After completing the benchmark, csv files will be generated in the current working directory.
- Clone excon
git clone https://github.com/excon/excon.git
- Remove Gemfile.lock, Uncomment benchmark gems in Gemfile.
bundle update; bundle install
- Run benchmark
ruby benchmarks/excon_vs.rb
Benchmark results as of Sep 28 2015 using ruby 2.2.3p173
$ ruby benchmarks/excon_vs.rb
[curb (persistent), em-http-request, Excon, Excon (persistent),
HTTParty, Net::HTTP, Net::HTTP (persistent), open-uri, RestClient,
StreamlyFFI (persistent), Typhoeus]
+--------------------------+-----------+
| tach | total |
+--------------------------+-----------+
| curb (persistent) | 3.057517 |
+--------------------------+-----------+
| StreamlyFFI (persistent) | 3.059292 |
+--------------------------+-----------+
| Typhoeus | 3.239624 |
+--------------------------+-----------+
| Net::HTTP | 3.842151 |
+--------------------------+-----------+
| Net::HTTP (persistent) | 3.890256 |
+--------------------------+-----------+
| HTTParty | 4.075583 |
+--------------------------+-----------+
| open-uri | 4.141922 |
+--------------------------+-----------+
| em-http-request | 4.371949 |
+--------------------------+-----------+
| Excon (persistent) | 4.873912 |
+--------------------------+-----------+
| Excon | 5.310598 |
+--------------------------+-----------+
| RestClient | 24.220251 |
+--------------------------+-----------+
Gems used:
Resolving dependencies.....
Using rake 10.4.2
Using i18n 0.7.0
Using json 1.8.3
Using minitest 5.8.1
Using thread_safe 0.3.5
Using tzinfo 1.2.2
Using activesupport 4.2.4
Using addressable 2.3.8
Using chronic 0.10.2
Using cookiejar 0.3.2
Using curb 0.8.8
Using ffi 1.9.10
Using curl_ffi 0.0.8
Using delorean 2.1.0
Using unf_ext 0.0.7.1
Using unf 0.1.4
Using domain_name 0.5.24
Using eventmachine 1.0.8
Using em-socksify 0.3.1
Using http_parser.rb 0.6.0
Using em-http-request 1.1.2
Using ethon 0.8.0
Using excon 0.45.4 from source at .
Using formatador 0.2.5
Using http-cookie 1.0.2
Using multi_xml 0.5.5
Using httparty 0.13.7
Using kgio 2.10.0
Using mime-types 2.6.2
Using netrc 0.10.3
Using open4 1.3.4
Using rack 1.6.4
Using rack-protection 1.5.3
Using raindrops 0.15.0
Using rdoc 4.2.0
Using rest-client 1.8.0
Using shindo 0.3.8
Using tilt 2.0.1
Using sinatra 1.4.6
Using streamly_ffi 0.2.6
Using tach 0.0.8
Using typhoeus 0.8.0
Using unicorn 4.9.0
Using bundler 1.10.6
Bundle updated!