Webサーバのベンチマークをとるのが趣味になりつつあるmatsumotoryです。
Webサーバのベンチマークについては、abからはじまりwrk等を使っていたのですが、最近ではほぼh2loadを使っています。
h2loadはnghttp2というHTTP/2ライブラリのアプリケーションに含まれているツールですが、
- HTTP/2(SPDYも)とHTTP/1.xに両対応している
- ベンチマーク側の同時スレッド数を増やせる
- SNIもサポートしている
- 最小、最大、平均、標準偏差あたりもちゃんとでる
ので、色々プロトコルを変えつつ同じベンチマークで値の目安を出すにはとても重宝しています。
Nghttp2: HTTP/2 C Library - nghttp2.org
実行結果のサンプルは例えば以下、
$ h2load -c 100 -n 10000 https://localhost:58082/ starting benchmark... spawning thread #0: 100 total client(s). 10000 total requests TLS Protocol: TLSv1.2 Cipher: ECDHE-RSA-AES128-GCM-SHA256 Server Temp Key: ECDH P-256 256 bits Application protocol: http/1.1 progress: 10% done progress: 20% done progress: 30% done progress: 40% done progress: 50% done progress: 60% done progress: 70% done progress: 80% done progress: 90% done progress: 100% done finished in 300.79ms, 33245.34 req/s, 4.14MB/s requests: 10000 total, 10000 started, 10000 done, 10000 succeeded, 0 failed, 0 errored, 0 timeout status codes: 10000 2xx, 0 3xx, 0 4xx, 0 5xx traffic: 1306800 bytes total, 859500 bytes headers (space savings 0.00%), 110000 bytes data min max mean sd +/- sd time for request: 16.04ms 225.26ms 115.41ms 59.69ms 56.07% time for connect: 49.75ms 101.39ms 56.42ms 5.38ms 87.00% time to 1st byte: 67.78ms 279.02ms 100.17ms 23.69ms 78.00% req/s : 343.79 850.22 449.69 204.01 79.00%
ちゃんとHTTP/1.1を検出してくれたり、HTTP/2に対しては、
$ h2load -c 100 -n 10000 https://localhost:8080/index.html starting benchmark... spawning thread #0: 100 total client(s). 10000 total requests TLS Protocol: TLSv1.2 Cipher: ECDHE-RSA-AES128-GCM-SHA256 Server Temp Key: ECDH P-256 256 bits Application protocol: h2 progress: 10% done progress: 20% done progress: 30% done progress: 40% done progress: 50% done progress: 60% done progress: 70% done progress: 80% done progress: 90% done progress: 100% done finished in 2.12s, 4714.33 req/s, 229.61KB/s requests: 10000 total, 10000 started, 10000 done, 10000 succeeded, 0 failed, 0 errored, 0 timeout status codes: 10000 2xx, 0 3xx, 0 4xx, 0 5xx traffic: 498746 bytes total, 95746 bytes headers (space savings 92.09%), 220000 bytes data min max mean sd +/- sd time for request: 167.45ms 1.87s 1.12s 553.00ms 63.00% time for connect: 47.93ms 313.94ms 89.12ms 69.25ms 90.00% time to 1st byte: 215.82ms 2.11s 1.21s 587.02ms 63.00% req/s : 47.35 443.00 125.54 108.58 87.00%
というように自動で検知してくれて非常に便利です。今後、TLSやHTTP/2、SPDYとか色々と混在した環境では非常に重宝するかと思います。Unix Domain Socketにも対応していると個人的な用途ではさらに便利だと思っています。
今後はHTTP/1についてもこれでやっていこうかなぁと思います。