Blog » Blog Entry

Benchmarking Rails: Mongrel versus mod_rails

June 1, 2008

After I setup one of my Rails applications to use mod_rails yesterday, I decided today to benchmark the new setup against my old Mongrel setup. In a nutshell, I found mod_rails to be slightly faster. It certainly wasn't a huge margin of victory, but I'll take it. :)

I ran these benchmark tests three times each and took the best ones. I did this to account for other traffic the server might have been getting for other sites that live there too. Not that it matters much, it's a Sunday morning and my server was under no real load to start with.

So here are my Mongrel versus mod_rails benchmarks, using ApacheBench, Version 2.0.40:

First, my old setup using Mongrel, ran twice with different concurrences and requests.

Server Load got up to 1.37 on this one using "-n 1000 -c 5":

> ab -n 1000 -c 5 http://pejorativewritings.com/
...
Finished 1000 requests

Server Software:        Mongrel
Server Hostname:        pejorativewritings.com
Server Port:            80

Document Path:          /
Document Length:        18944 bytes

Concurrency Level:      5
Time taken for tests:   437.515036 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      19342000 bytes
HTML transferred:       18944000 bytes
Requests per second:    2.29 [#/sec] (mean)
Time per request:       2187.575 [ms] (mean)
Time per request:       437.515 [ms] (mean, across all concurrent requests)
Transfer rate:          43.17 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1  22.2      0     353
Processing:   509 2182 341.8   2157    6506
Waiting:      498 2168 343.9   2141    6505
Total:        509 2183 338.8   2157    6506

Percentage of the requests served within a certain time (ms)
  50%   2157
  66%   2188
  75%   2201
  80%   2206
  90%   2225
  95%   2301
  98%   2550
  99%   4326
 100%   6506 (longest request)

Server Load got up to 1.13 on this one using "-n 500 -c 1":

> ab -n 500 -c 1 http://pejorativewritings.com/
...
Finished 500 requests

Server Software:        Mongrel
Server Hostname:        pejorativewritings.com
Server Port:            80

Document Path:          /
Document Length:        18944 bytes

Concurrency Level:      1
Time taken for tests:   215.731642 seconds
Complete requests:      500
Failed requests:        0
Write errors:           0
Total transferred:      9671000 bytes
HTML transferred:       9472000 bytes
Requests per second:    2.32 [#/sec] (mean)
Time per request:       431.463 [ms] (mean)
Time per request:       431.463 [ms] (mean, across all concurrent requests)
Transfer rate:          43.78 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.0      0       0
Processing:   346  430  91.3    474     951
Waiting:        5  429  93.1    473     950
Total:        346  430  91.3    474     951

Percentage of the requests served within a certain time (ms)
  50%    474
  66%    481
  75%    484
  80%    486
  90%    495
  95%    502
  98%    783
  99%    871
 100%    951 (longest request)

Then here's my slightly faster mod_rails setup, ran twice with different concurrences and requests.

Server Load got up to 8.41 on this one using "-n 1000 -c 5":

> ab -n 1000 -c 5 http://pejorativewritings.com/
...
Finished 1000 requests

Server Software:        Apache
Server Hostname:        pejorativewritings.com
Server Port:            80

Document Path:          /
Document Length:        18944 bytes

Concurrency Level:      5
Time taken for tests:   425.965844 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      19337023 bytes
HTML transferred:       18944000 bytes
Requests per second:    2.35 [#/sec] (mean)
Time per request:       2129.829 [ms] (mean)
Time per request:       425.966 [ms] (mean, across all concurrent requests)
Transfer rate:          44.33 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.1      0       2
Processing:   335 2128 3587.9    836   29834
Waiting:      334 2126 3587.5    835   29834
Total:        335 2128 3587.9    836   29834

Percentage of the requests served within a certain time (ms)
  50%    836
  66%   1270
  75%   2057
  80%   2587
  90%   5264
  95%   9009
  98%  15521
  99%  20504
 100%  29834 (longest request)

Server Load got up to 1.45 on this one using "-n 500 -c 1":

> ab -n 500 -c 1 http://pejorativewritings.com/
...
Finished 500 requests

Server Software:        Apache
Server Hostname:        pejorativewritings.com
Server Port:            80

Document Path:          /
Document Length:        18944 bytes

Concurrency Level:      1
Time taken for tests:   211.918140 seconds
Complete requests:      500
Failed requests:        0
Write errors:           0
Total transferred:      9668500 bytes
HTML transferred:       9472000 bytes
Requests per second:    2.36 [#/sec] (mean)
Time per request:       423.836 [ms] (mean)
Time per request:       423.836 [ms] (mean, across all concurrent requests)
Transfer rate:          44.55 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.0      0       0
Processing:   336  423 140.3    454    3076
Waiting:        4  420 142.6    453    3075
Total:        336  423 140.3    454    3076

Percentage of the requests served within a certain time (ms)
  50%    454
  66%    459
  75%    461
  80%    463
  90%    469
  95%    478
  98%    585
  99%    731
 100%   3076 (longest request)
Tags: ruby, rubyonrails, apache, mod_rails, mongrel

« More silly Zend Framework idiocy.. How To Deploy Rails Using mod_rails On Apache »

Add a comment:

Title:

Comment:

Name:

Email: