curb 0.7.3 performs as expected

drbrain | Wed, 19 May 2010 20:32:31 GMT

Posted in ,

Over loopback, curb runs about 2.4x the speed of net-http-persistent. This is the performance I expected curb to give. Having a pure-ruby library perform 2.4x worse than a C library makes net/http a fantastic library.

Remember, this benchmark and the previous one were designed to model a web-service type workload where many small requests are made. These benchmarks aren't designed to model downloading large files.

require 'rubygems'
require 'benchmark'
require 'net/http/persistent'
require 'curb'

# dd if=/dev/zero of=~/Sites/zeros-1k bs=1024 c=1
uri_1k  = URI.parse 'http://localhost/~drbrain/zeros-1k'
uri_2k  = URI.parse 'http://localhost/~drbrain/zeros-2k'
uri_10k = URI.parse 'http://localhost/~drbrain/zeros-10k'

uri = uri_2k

N = 100_000

Benchmark.bmbm do |bm|
  bm.report 'Net::HTTP::Persistent' do
    http_p = Net::HTTP::Persistent.new

    N.times do
      response = http_p.request uri
      response.body
    end
  end

  bm.report 'curb' do
    curl = Curl::Easy.new
    url = uri.to_s

    N.times do
      curl.url = url
      curl.perform
      curl.body_str
    end
  end
end
Rehearsal ---------------------------------------------------------
Net::HTTP::Persistent  54.070000   3.930000  58.000000 ( 71.651048)
curb                   11.800000   4.510000  16.310000 ( 30.930453)
----------------------------------------------- total: 74.310000sec

                            user     system      total        real
Net::HTTP::Persistent  54.130000   3.930000  58.060000 ( 72.430575)
curb                   11.860000   4.540000  16.400000 ( 30.804222)
comments

Comments RSS FEED

Hi Eric,

Thanks for sending me the information about the persistent connection issues in earlier versions of curb. I believe between version 0.5.x and 0.7.3 had that issue. I suspect a few factors in that 2.x difference is http parser speed, memory allocated…

Todd said 1 day later

No problem Todd!

Since curb sits atop libcurl it should be faster than the pure-ruby Net::HTTP. That it’s only 2.4x faster tells me that Net::HTTP is a damn good library.

Eric Hodel said 2 days later

Comments are disabled