2008-12-17

I did a little benchmark testing on some http client implementations on Ruby. I'm the author of httpclient (http-access2), one of a http client implementation for Ruby.

Environment:
  • HTTP Server:
  • Apache/2.2.9 (Ubuntu) mpm-worker
  • Ubuntu 8.10 32bit

HTTP Client:
Ruby: ruby 1.8.7 (2008-12-04 revision 20478) [i686-linux]
vendor:
eventmachine/0.12.2(*)
rfuzz/0.9
net/http (svn ruby_1_8)
httpclient/2.1.3-RC
open-uri (svn ruby_1_8) (net/http wrapper)
httparty/0.2.2 (net/http wrapper)
(*) EM::Protocols::HttpClient2 is not listed below because it does
not work when requests > 20 on my env.

HTTP Server and HTTP clients runs on the same host.

Benchmark suite:
http://dev.ctor.org/http-access2/browser/trunk/bench/bm.rb
proxy = nil
url = http://127.0.0.1/
threads = 2
requests = 250

Result:
HTTP Server KeeyAlive: Off
user system total real
curb 0.050000 0.420000 0.470000 ( 0.807049)
RFuzz::HttpClient 0.090000 0.430000 0.520000 ( 0.803075)
Net::HTTP 0.280000 0.520000 0.800000 ( 1.147281)
HTTPClient 0.140000 0.800000 0.940000 ( 1.299928)
open-uri 0.420000 0.880000 1.300000 ( 1.675272)
HTTParty 0.490000 0.620000 1.110000 ( 1.483024)

HTTP Server KeeyAlive: On
user system total real
curb 0.100000 0.460000 0.560000 ( 51.170485)
RFuzz::HttpClient 0.030000 0.580000 0.610000 ( 1.001198)
Net::HTTP 0.150000 0.490000 0.640000 ( 0.842344)
HTTPClient 0.140000 0.460000 0.600000 ( 0.801035)
open-uri 0.740000 0.740000 1.480000 ( 1.870712)
HTTParty 0.710000 0.880000 1.590000 ( 2.555711)

Considerations:
1. EM::Protocols::HttpClient2 does not work on my env. Is the
client code right?
2. curb needs too much 'real' time when connecting to KeepAlive: On
site. Is this expected?
3. rfuzz and curb are faster than net/http and httpclient when
connecting to KeepAlive: Off site.
4. net/http and httpclient run almost as fast as rfuzz when
connecting to KeepAlive: On site. Bear in mind that you need to call
Net::HTTP#start and #finish by yourself for keep-alive handling. Just
calling Net::HTTP#get takes 2 times longer than others. Bothersome?
Use others.

At the last, does somebody know how I can read
http://apocryph.org/more_indepth_analysis_ruby_http_client_performance
? I get 'Error establishing a database connection'.