WEBサーバーのデフォルト状態でのパフォーマンスを確認します。
環境
サーバー
- Xeon E5420(4core/2.5GHz) / Mem 4G
- Ubuntu18.04
WEBサーバーアプリケーション
- Apache 2.4.29 (event mpm)
- nginx 1.14.0
- H2O 2.3.0-beta1
Apacheのpreforkはもう時代遅れなので対象外
プロトコル
- httpプロトコル
- httpsプロトコル
SSL証明書はLet's Encryptのワイルドカード証明書を利用します
ベンチマークソフトウェア
- vegeta
事前準備
echo test > /var/www/html/test.html
検証結果
http/100同時接続
通常のベンチマークのレベルです
Apache
echo "GET http://apache.lovesaemi.daemon.asia:81/test.html" | vegeta attack -rate=100/s -duration=5s | vegeta report
Requests [total, rate] 500, 100.20
Duration [total, attack, wait] 4.990221181s, 4.989910973s, 310.208µs
Latencies [mean, 50, 95, 99, max] 266.966µs, 254.706µs, 315.678µs, 615.864µs, 1.742608ms
Bytes In [total, mean] 2500, 5.00
Bytes Out [total, mean] 0, 0.00
Success [ratio] 100.00%
Status Codes [code:count] 200:500
Error Set:
Nginx
echo "GET http://nginx.lovesaemi.daemon.asia:82/test.html" | vegeta attack -rate=100/s -duration=5s | vegeta report
Requests [total, rate] 500, 100.20
Duration [total, attack, wait] 4.990335713s, 4.99005168s, 284.033µs
Latencies [mean, 50, 95, 99, max] 238.008µs, 226.084µs, 304.047µs, 574.479µs, 1.178932ms
Bytes In [total, mean] 2500, 5.00
Bytes Out [total, mean] 0, 0.00
Success [ratio] 100.00%
Status Codes [code:count] 200:500
Error Set:
H2O
echo "GET http://h2o.lovesaemi.daemon.asia:83/test.html" | vegeta attack -rate=100/s -duration=5s | vegeta report
Requests [total, rate] 500, 100.20
Duration [total, attack, wait] 4.990236541s, 4.990026913s, 209.628µs
Latencies [mean, 50, 95, 99, max] 194.883µs, 186.153µs, 246.128µs, 292.554µs, 1.504034ms
Bytes In [total, mean] 2500, 5.00
Bytes Out [total, mean] 0, 0.00
Success [ratio] 100.00%
Status Codes [code:count] 200:500
Error Set:
https/100同時接続
Apache
echo "GET https://apache.lovesaemi.daemon.asia:4431/test.html" | vegeta attack -rate=100/s -duration=5s | vegeta report
Requests [total, rate] 500, 100.20
Duration [total, attack, wait] 4.990364791s, 4.990062158s, 302.633µs
Latencies [mean, 50, 95, 99, max] 1.262118ms, 288.951µs, 377.28µs, 48.968526ms, 93.449723ms
Bytes In [total, mean] 2500, 5.00
Bytes Out [total, mean] 0, 0.00
Success [ratio] 100.00%
Status Codes [code:count] 200:500
Error Set:
Nginx
echo "GET https://nginx.lovesaemi.daemon.asia:4432/test.html" | vegeta attack -rate=100/s -duration=5s | vegeta report
Requests [total, rate] 500, 100.20
Duration [total, attack, wait] 4.99025735s, 4.990003451s, 253.899µs
Latencies [mean, 50, 95, 99, max] 1.012768ms, 236.33µs, 297.705µs, 37.946284ms, 82.943596ms
Bytes In [total, mean] 2500, 5.00
Bytes Out [total, mean] 0, 0.00
Success [ratio] 100.00%
Status Codes [code:count] 200:500
Error Set:
H2O
echo "GET https://h2o.lovesaemi.daemon.asia:4433/test.html" | vegeta attack -rate=100/s -duration=5s | vegeta report
Requests [total, rate] 500, 100.20
Duration [total, attack, wait] 4.990194327s, 4.99000026s, 194.067µs
Latencies [mean, 50, 95, 99, max] 1.047869ms, 187.496µs, 267.842µs, 42.330876ms, 87.177305ms
Bytes In [total, mean] 2500, 5.00
Bytes Out [total, mean] 0, 0.00
Success [ratio] 100.00%
Status Codes [code:count] 200:500
Error Set:
http/1000同時接続
強めのYahoo砲ぐらい(知らんけど)のレベルです。これがさばければ十分
Apache
echo "GET http://apache.lovesaemi.daemon.asia:81/test.html" | vegeta attack -rate=1000/s -duration=5s | vegeta report
Requests [total, rate] 5000, 1000.20
Duration [total, attack, wait] 4.999225118s, 4.999008674s, 216.444µs
Latencies [mean, 50, 95, 99, max] 245.08µs, 234.823µs, 278.673µs, 544.736µs, 3.739972ms
Bytes In [total, mean] 25000, 5.00
Bytes Out [total, mean] 0, 0.00
Success [ratio] 100.00%
Status Codes [code:count] 200:5000
Error Set:
Nginx
echo "GET http://nginx.lovesaemi.daemon.asia:82/test.html" | vegeta attack -rate=1000/s -duration=5s | vegeta report
Requests [total, rate] 5000, 1000.19
Duration [total, attack, wait] 4.999298955s, 4.999058926s, 240.029µs
Latencies [mean, 50, 95, 99, max] 214.1µs, 205.515µs, 239.533µs, 467.101µs, 3.671936ms
Bytes In [total, mean] 25000, 5.00
Bytes Out [total, mean] 0, 0.00
Success [ratio] 100.00%
Status Codes [code:count] 200:5000
Error Set:
H2O
echo "GET http://h2o.lovesaemi.daemon.asia:83/test.html" | vegeta attack -rate=1000/s -duration=5s | vegeta report
Requests [total, rate] 5000, 1000.20
Duration [total, attack, wait] 4.99917753s, 4.999005231s, 172.299µs
Latencies [mean, 50, 95, 99, max] 189.941µs, 181.649µs, 215.039µs, 262.817µs, 6.065797ms
Bytes In [total, mean] 25000, 5.00
Bytes Out [total, mean] 0, 0.00
Success [ratio] 100.00%
Status Codes [code:count] 200:5000
Error Set:
https/1000同時接続
Apache
echo "GET https://apache.lovesaemi.daemon.asia:4431/test.html" | vegeta attack -rate=1000/s -duration=5s | vegeta report
Requests [total, rate] 5000, 987.09
Duration [total, attack, wait] 7.822974316s, 5.065415424s, 2.757558892s
Latencies [mean, 50, 95, 99, max] 1.586650398s, 1.484027894s, 3.792878437s, 5.042307698s, 6.659751398s
Bytes In [total, mean] 25000, 5.00
Bytes Out [total, mean] 0, 0.00
Success [ratio] 100.00%
Status Codes [code:count] 200:5000
Error Set:
Nginx
echo "GET https://nginx.lovesaemi.daemon.asia:4432/test.html" | vegeta attack -rate=1000/s -duration=5s | vegeta report
Requests [total, rate] 5000, 1000.19
Duration [total, attack, wait] 4.999678105s, 4.99903959s, 638.515µs
Latencies [mean, 50, 95, 99, max] 25.655742ms, 233.209µs, 235.999202ms, 357.130794ms, 536.58896ms
Bytes In [total, mean] 25000, 5.00
Bytes Out [total, mean] 0, 0.00
Success [ratio] 100.00%
Status Codes [code:count] 200:5000
Error Set:
H2O
echo "GET https://h2o.lovesaemi.daemon.asia:4433/test.html" | vegeta attack -rate=1000/s -duration=5s | vegeta report
Requests [total, rate] 5000, 1000.21
Duration [total, attack, wait] 4.999334281s, 4.998975027s, 359.254µs
Latencies [mean, 50, 95, 99, max] 7.208288ms, 192.451µs, 20.286775ms, 208.290533ms, 281.67586ms
Bytes In [total, mean] 25000, 5.00
Bytes Out [total, mean] 0, 0.00
Success [ratio] 100.00%
Status Codes [code:count] 200:5000
Error Set:
(おまけ)http/10000同時接続
趣味やCDNの世界
Apache
echo "GET http://apache.lovesaemi.daemon.asia:81/test.html" | vegeta attack -rate=10000/s -duration=5s | vegeta report
Requests [total, rate] 50000, 10000.01
Duration [total, attack, wait] 5.000266429s, 4.999995086s, 271.343µs
Latencies [mean, 50, 95, 99, max] 1.221735ms, 369.475µs, 5.939544ms, 17.012495ms, 33.864936ms
Bytes In [total, mean] 250000, 5.00
Bytes Out [total, mean] 0, 0.00
Success [ratio] 100.00%
Status Codes [code:count] 200:50000
Error Set:
Nginx
echo "GET http://nginx.lovesaemi.daemon.asia:82/test.html" | vegeta attack -rate=10000/s -duration=5s | vegeta report
Requests [total, rate] 50000, 9999.05
Duration [total, attack, wait] 5.000834889s, 5.000476098s, 358.791µs
Latencies [mean, 50, 95, 99, max] 257.782µs, 179.052µs, 575.762µs, 1.894675ms, 7.018147ms
Bytes In [total, mean] 250000, 5.00
Bytes Out [total, mean] 0, 0.00
Success [ratio] 100.00%
Status Codes [code:count] 200:50000
Error Set:
H2O
echo "GET http://h2o.lovesaemi.daemon.asia:83/test.html" | vegeta attack -rate=10000/s -duration=5s | vegeta report
Requests [total, rate] 50000, 10000.02
Duration [total, attack, wait] 5.000186662s, 4.999988381s, 198.281µs
Latencies [mean, 50, 95, 99, max] 190.588µs, 150.516µs, 334.052µs, 1.123529ms, 4.01662ms
Bytes In [total, mean] 250000, 5.00
Bytes Out [total, mean] 0, 0.00
Success [ratio] 100.00%
Status Codes [code:count] 200:50000
Error Set:
評価
- H2O強い
- vegetaのみかたよくわからん罠
- httpsで1000req/secがさばければ十分なのでどのサーバーソフトウェアを選んでも間違いない
- NginxやH2Oがサーバー負荷的には良い選択だとおもう。(Load Averageの上がり方が少ない)
- Apacheは虎の子の.htaccessがあるので非常なアドバンテージがある
- 設定がともかく楽だったのでH2Oを使いたい
- Nginxは高性能、H2Oは超性能
- mrubyを使いこなしたH2Oはさいつよ