rubyとpython、httpd性能で大違いというエントリを読んだのだが、よく分からなかったので軽く確認してみた。
きっちりベンチマークを取ったのではなく、軽く試した程度なので全く当てにならない数値であることを先に記しておく。
(役に立つ数字では決してないためあえてRuby
やPython
と言ったタグは設定していない)
確認方法
Apache Benchでリクエストを投げる。
簡単に確認したいだけだったので数字は適当。
$ ab -n 100 -c 100 http://127.0.0.1:8000/
動作環境
- Windows 7 Pro(32bit版)
- Ruby 2.3.0
- Python 2.7.12
$ ruby -v
ruby 2.3.0p0 (2015-12-25 revision 53290) [i386-mingw32]
$ python --version
Python 2.7.12
実行方法
適当にドキュメントルートとなるディレクトリを作成し、下記index.html
を配置。
<html><body>foo</body></html>
Ruby
$ ruby -rwebrick -e 'WEBrick::HTTPServer.new(:DocumentRoot => "./", :Port => 8000).start'
Python
$ python -m SimpleHTTPServer
結果
Ruby
This is ApacheBench, Version 2.3 <$Revision: 1706008 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 127.0.0.1 (be patient).....done
Server Software: WEBrick/1.3.1
Server Hostname: 127.0.0.1
Server Port: 8000
Document Path: /
Document Length: 31 bytes
Concurrency Level: 100
Time taken for tests: 0.160 seconds
Complete requests: 100
Failed requests: 0
Total transferred: 27900 bytes
HTML transferred: 3100 bytes
Requests per second: 625.00 [#/sec] (mean)
Time per request: 160.000 [ms] (mean)
Time per request: 1.600 [ms] (mean, across all concurrent requests)
Transfer rate: 170.29 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.4 0 1
Processing: 19 80 35.4 82 138
Waiting: 19 79 35.4 81 137
Total: 19 80 35.4 82 138
Percentage of the requests served within a certain time (ms)
50% 82
66% 101
75% 112
80% 118
90% 129
95% 135
98% 137
99% 138
100% 138 (longest request)
Python
This is ApacheBench, Version 2.3 <$Revision: 1706008 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 127.0.0.1 (be patient).....done
Server Software: SimpleHTTP/0.6
Server Hostname: 127.0.0.1
Server Port: 8000
Document Path: /
Document Length: 31 bytes
Concurrency Level: 100
Time taken for tests: 8.060 seconds
Complete requests: 100
Failed requests: 0
Total transferred: 21600 bytes
HTML transferred: 3100 bytes
Requests per second: 12.41 [#/sec] (mean)
Time per request: 8060.000 [ms] (mean)
Time per request: 80.600 [ms] (mean, across all concurrent requests)
Transfer rate: 2.62 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 80 184.6 0 509
Processing: 7 4111 2436.8 4038 8050
Waiting: 7 4107 2437.5 4034 8048
Total: 8 4191 2432.7 4038 8050
Percentage of the requests served within a certain time (ms)
50% 4038
66% 5549
75% 6548
80% 6550
90% 7548
95% 8049
98% 8050
99% 8050
100% 8050 (longest request)
いくらなんでも数字が違いすぎたので時間を置いて何度か実行してみたが、大体同じ数字になった。
そもそも実行環境の時点で参考にならないものであるが、こういう結果が出たという備忘録として残しておく。