Thursday, August 08, 2013

Ruby 1.9.3 (Rails 3) Ruby 2.0 (Rails 4) Performance test and improvements

Using Mac OS and Webrick in local environment
time -p bundle exec rake environment
real 6.69
user 4.76
sys 0.79

export RUBY_GC_MALLOC_LIMIT=1000000000
export RUBY_FREE_MIN=500000
export RUBY_HEAP_MIN_SLOTS=40000

AFTER we set the above exports , check the below performance
time -p bundle exec rake environment
real 5.36
user 3.19
sys 1.05

Also tested in request to response scenario using apache bench with 100 requests
Ruby 1.9.3 (Rails 3)
------------------------------------------------------------------------------------------
ab -n 100 -c 1 http://localhost:3000/
------------------------------------------------------------------------------------------
BEFORE FLAGS SET  (ruby-1.9.3-p194 [ x86_64 ])
------------------------------
Server Software:        WEBrick/1.3.1
Server Hostname:        127.0.0.1
Server Port:            3000

Document Path:          /
Document Length:        96050 bytes

Concurrency Level:      1
Time taken for tests:   391.883 seconds
Complete requests:      100
Failed requests:        13
   (Connect: 0, Receive: 0, Length: 13, Exceptions: 0)
Write errors:           0
Total transferred:      9698686 bytes
HTML transferred:       9604985 bytes
Requests per second:    0.26 [#/sec] (mean)
Time per request:       3918.831 [ms] (mean)
Time per request:       3918.831 [ms] (mean, across all concurrent requests)
Transfer rate:          24.17 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:     2963 3585 583.6   3430    5625
Processing:     0  334 2625.5      1   26154
Waiting:        0  333 2625.5      0   26153
Total:       2963 3919 2905.2   3430   31529

Percentage of the requests served within a certain time (ms)
  50%   3430
  66%   3532
  75%   3623
  80%   3710
  90%   4407
  95%   6346
  98%   7244
  99%  31529
 100%  31529 (longest request)
---------------------------------------------------------------
AFTER FLAGS SET  (ruby-1.9.3-p194 [ x86_64 ])
---------------------------------------------------------------
export RUBY_GC_MALLOC_LIMIT=1000000000
export RUBY_FREE_MIN=500000
export RUBY_HEAP_MIN_SLOTS=40000

Server Software:        WEBrick/1.3.1
Server Hostname:        127.0.0.1
Server Port:            3000

Document Path:          /
Document Length:        96050 bytes

Concurrency Level:      1
Time taken for tests:   368.903 seconds
Complete requests:      100
Failed requests:        14
   (Connect: 0, Receive: 0, Length: 14, Exceptions: 0)
Write errors:           0
Total transferred:      9714323 bytes
HTML transferred:       9620622 bytes
Requests per second:    0.27 [#/sec] (mean)
Time per request:       3689.025 [ms] (mean)
Time per request:       3689.025 [ms] (mean, across all concurrent requests)
Transfer rate:          25.72 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:     2563 3388 634.5   3395    5351
Processing:     0  301 2692.0      0   26860
Waiting:        0  301 2692.0      0   26859
Total:       2563 3689 2973.1   3397   32211

Percentage of the requests served within a certain time (ms)
  50%   3397
  66%   3656
  75%   3753
  80%   3809
  90%   3928
  95%   5208
  98%   6949
  99%  32211
 100%  32211 (longest request)
----------------------------------------------------

Ruby 2.0 (Rails 4)
-------------------------------------------------------------------------------------------------------
 ab -n 100 -c 1 http://127.0.0.1:3000/
------------------------------------------------------------------------------------------------------
Server Software:        WEBrick/1.3.1
Server Hostname:        127.0.0.1
Server Port:            3000

Document Path:          /?locale=uk
Document Length:        20815 bytes

Concurrency Level:      1
Time taken for tests:   181.485 seconds
Complete requests:      100
Failed requests:        5
   (Connect: 0, Receive: 0, Length: 5, Exceptions: 0)
Write errors:           0
Total transferred:      2185395 bytes
HTML transferred:       2081495 bytes
Requests per second:    0.55 [#/sec] (mean)
Time per request:       1814.851 [ms] (mean)
Time per request:       1814.851 [ms] (mean, across all concurrent requests)
Transfer rate:          11.76 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:       37 1590 658.0   1678    5320
Processing:     0  225 918.2      0    8042
Waiting:        0  225 917.9      0    8041
Total:       1585 1815 818.9   1679    8079

Percentage of the requests served within a certain time (ms)
  50%   1679
  66%   1685
  75%   1690
  80%   1694
  90%   1749
  95%   1995
  98%   6240
  99%   8079
 100%   8079 (longest request)
-------------------------------------------------------------------------------------------------
AFTER FLAG SET (Ruby 2.0 (Rails 4)
export RUBY_GC_MALLOC_LIMIT=1000000000
export RUBY_FREE_MIN=500000
export RUBY_HEAP_MIN_SLOTS=40000
----------
Server Software:        WEBrick/1.3.1
Server Hostname:        127.0.0.1
Server Port:            3000

Document Path:          /?locale=uk
Document Length:        20815 bytes

Concurrency Level:      1
Time taken for tests:   172.496 seconds
Complete requests:      100
Failed requests:        12
   (Connect: 0, Receive: 0, Length: 12, Exceptions: 0)
Write errors:           0
Total transferred:      2185386 bytes
HTML transferred:       2081486 bytes
Requests per second:    0.58 [#/sec] (mean)
Time per request:       1724.962 [ms] (mean)
Time per request:       1724.962 [ms] (mean, across all concurrent requests)
Transfer rate:          12.37 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:       36  350 695.0     40    3408
Processing:     0 1374 737.0   1564    3935
Waiting:        0 1374 736.6   1563    3934
Total:       1582 1725 406.2   1607    3973

Percentage of the requests served within a certain time (ms)
  50%   1607
  66%   1617
  75%   1640
  80%   1651
  90%   1909
  95%   3031
  98%   3408
  99%   3973
 100%   3973 (longest request)