(mongrel && ruby1.9).kind_of? TrueClass

Finally mongrel builds and run on ruby 1.9. There are no optimizations for it yet (the new thread model of ruby 1.9 can delivery a performance boost for mongrel) and there is at least one known issue (CTRL+C doesn’t exit after waiting for the server finish all the requests: it just close all connections), but at least it’s possible to test it. I wrote a small benchmark using only mongrel (out of the rails) running behind apache2.2 with mod_proxy (5 mongrel instances, 5 for 1.8 and 5 for 1.9), all running in a vmware debian etch machine, and here are some results:
yggdrasil-iv:~# ab -c 10 -n 10000 http://localhost/rb18 2>/dev/null # ruby 1.8
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright 2006 The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)

Server Software: Apache/2.2.3
Server Hostname: localhost
Server Port: 80

Document Path: /rb18
Document Length: 276 bytes

Concurrency Level: 10
Time taken for tests: 5.326544 seconds
Complete requests: 10000
Failed requests: 0
Write errors: 0
Non-2xx responses: 10008
Total transferred: 4553640 bytes
HTML transferred: 2762208 bytes
Requests per second: 1877.39 [#/sec] (mean)
Time per request: 5.327 [ms] (mean)
Time per request: 0.533 [ms] (mean, across all concurrent requests)
Transfer rate: 834.69 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 1 1.3 2 11
Processing: 1 2 1.3 3 12
Waiting: 0 1 1.1 2 11
Total: 4 4 1.5 4 19

Percentage of the requests served within a certain time (ms)
50% 4
66% 4
75% 5
80% 5
90% 6
95% 7
98% 9
99% 11
100% 19 (longest request)

yggdrasil-iv:~# ab -c 10 -n 10000 http://localhost/rb19 2>/dev/null # ruby 1.9
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright 2006 The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)

Server Software: Apache/2.2.3
Server Hostname: localhost
Server Port: 80

Document Path: /rb19
Document Length: 276 bytes

Concurrency Level: 10
Time taken for tests: 4.932474 seconds
Complete requests: 10000
Failed requests: 0
Write errors: 0
Non-2xx responses: 10000
Total transferred: 4550000 bytes
HTML transferred: 2760000 bytes
Requests per second: 2027.38 [#/sec] (mean)
Time per request: 4.932 [ms] (mean)
Time per request: 0.493 [ms] (mean, across all concurrent requests)
Transfer rate: 900.76 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 1 1 1.1 2 18
Processing: 1 2 1.1 3 17
Waiting: 0 1 1.0 1 14
Total: 3 4 1.1 4 22

Percentage of the requests served within a certain time (ms)
50% 4
66% 4
75% 4
80% 4
90% 5
95% 5
98% 7
99% 9
100% 22 (longest request)

As you can see, the performance is almost the same. mongrel + ruby1.8 performed around 1800-2100 requests per second, while mongrel+ruby1.9 performed around 2000-2100 requests per second. So, happiness happiness happiness: it seems that mongrel is running just fine(TM) on ruby 1.9. Probably there are some hidden bugs here and there, but life goes on and we will find it with time. Also, there are some ruby 1.9 bugs around, including one that makes one mongrel test fail (see my last post).

Also, always remember: this is just a benchmark. Do not try ruby1.9 to real world things yet. Wait for ruby 1.9.1 or 2.0…

Oh, the server script used to this test is here:

require ‘mongrel’

class SimpleHandler < Mongrel::HttpHandler
def process(request, response)
response.start do |head,out|
head["Content-Type"] = "text/html"

results = "Your request:#{request.params.to_yaml}"
out << results
end
end
end

class PerfTest

def initialize port
@servers = Array.new
@server = Mongrel::Configurator.new :host => ‘127.0.0.1′, :port => port do
listener do
uri “/”, :handler => SimpleHandler.new
end
end
end

def run
print “Starting… ”
server_process = @server.run
print “OK!\n”
server_process.join

end

def teardown
@server.stop(false, true)
end

end

port = ARGV[0].to_i || 4000
tst = PerfTest.new port
tst.run

One Response to “(mongrel && ruby1.9).kind_of? TrueClass”

  1. Ruby 1.9 porting notes « Boga Mac blog Says:

    [...] Mongrel on ruby1.9 [...]

Leave a Reply

You must be logged in to post a comment.