2010/04/01


rubyのmongrelやthinなんかに変わるhttpdでUnicornとやらがあるのを知った。
ひとまずベンチ取ってみた。rubyでやる専用なのでなにかアプリを書かないと動かないのかな?とりあえずsinatraアプリ書いた。

unicorn-test.rb
require 'rubygems'
require 'sinatra'
set :public, File.dirname(__FILE__)
config.ru
require 'unicorn-test'
run Sinatra::Application
で、unicorn実行。ベンチは
# ab -n 1000 -c 10 -k http://localhost:8080/helloworld.html 2>&1 | tee unicorn.log
で確認した。

unicornの結果

This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests


Server Software:        
Server Hostname:        localhost
Server Port:            8080

Document Path:          /helloworld.html
Document Length:        11 bytes

Concurrency Level:      10
Time taken for tests:   5.385 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Keep-Alive requests:    0
Total transferred:      193386 bytes
HTML transferred:       11022 bytes
Requests per second:    185.69 [#/sec] (mean)
Time per request:       53.855 [ms] (mean)
Time per request:       5.385 [ms] (mean, across all concurrent requests)
Transfer rate:          35.07 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.1      0       1
Processing:    12   53  43.2     33     260
Waiting:       11   53  43.1     32     260
Total:         12   54  43.1     33     260

Percentage of the requests served within a certain time (ms)
  50%     33
  66%     42
  75%     56
  80%    106
  90%    119
  95%    140
  98%    176
  99%    212
 100%    260 (longest request)
一応、prefork付きのapache2でも...
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests


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

Document Path:          /helloworld.html
Document Length:        11 bytes

Concurrency Level:      10
Time taken for tests:   0.341 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Keep-Alive requests:    996
Total transferred:      322825 bytes
HTML transferred:       11000 bytes
Requests per second:    2931.25 [#/sec] (mean)
Time per request:       3.412 [ms] (mean)
Time per request:       0.341 [ms] (mean, across all concurrent requests)
Transfer rate:          924.10 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.1      0       1
Processing:     0    3   7.8      0      40
Waiting:        0    3   7.8      0      40
Total:          0    3   7.8      0      40

Percentage of the requests served within a certain time (ms)
  50%      0
  66%      0
  75%      0
  80%      0
  90%     18
  95%     21
  98%     32
  99%     35
 100%     40 (longest request)
いちおうのいちおうでtthttpd(tinytinyhttpd)でも
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests


Server Software:        
Server Hostname:        localhost
Server Port:            8081

Document Path:          /helloworld.html
Document Length:        11 bytes

Concurrency Level:      10
Time taken for tests:   0.431 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Keep-Alive requests:    1000
Total transferred:      183000 bytes
HTML transferred:       11000 bytes
Requests per second:    2321.65 [#/sec] (mean)
Time per request:       4.307 [ms] (mean)
Time per request:       0.431 [ms] (mean, across all concurrent requests)
Transfer rate:          414.90 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.1      0       1
Processing:     0    4  15.1      0     241
Waiting:        0    4  15.0      0     241
Total:          0    4  15.1      0     241

Percentage of the requests served within a certain time (ms)
  50%      0
  66%      0
  75%      0
  80%      0
  90%      7
  95%     29
  98%     44
  99%     54
 100%    241 (longest request)

結論: preforkつえー。


えっ?そういう調査でしたっけ...
Posted at by | Edit