HTTP/2 に対応するベンチマークツール h2load を Build するメモ

Linux
この記事は約6分で読めます。
この記事は最終更新日より 1 年以上経過しています。
画像やリンクが無効になっている可能性もあるのでご了承下さい。

 最近嵌まっていることは HTTP/2 への対応に向けた検証作業。VMware で CentOS 7 をインスコしたテスト環境を作って Nginx 1.9.9 を用いて実現させようとしている最中というステータス。Apache 2.4.17 以降で HTTP/2 を実装しようとすると、現状ではソースからビルドしなくちゃいけないし、必要なライブラリ群も合わせてビルドする必要がある。メンテナンスがなおざりになりそうだし、もっと実装の簡単な Nginx に目を向けたというわけ。

 どれだけリクエストを裁けるかを計測する為には、既存であれば ApacheBench や httpress があるけど今現在では HTTP/2 には非対応。HTTP/2 対応の同種の物では h2load があって nghttp2 というパッケージに含まれており、これは yum で導入が可能。しかし、パッケージで導入した h2load は Version 1.2.1 で今度は HTTP/1.1 に非対応となる。HTTP 1.1/2.0 両対応するには nghttp2 のソースからビルドする必要があった。
 ビルド自体は単純なんだけど、依存関係にあるパッケージの導入がとにかく面倒だった。とりあえず不足する物を試行錯誤しつつ導入していった物を纏めた結果は次の様になった。

sudo yum install m4 autoconf perl-Thread-Queue automake libtool xz-devel libxml2-devel libevent libevent-devel CUnit CUnit-devel libstdc++-devel gcc-c++ libtool-ltdl-devel openssl-static python-devel libev-devel c-ares c-ares-devel jansson jansson-devel

 これだけ不足していたので、足りない物を探すのが怠かった。
 あとは github のドキュメント通りに 2 つのソースをビルドしていく。

git clone https://github.com/tatsuhiro-t/spdylay.git
cd ./spdylay
autoreconf -i
automake
autoconf
./configure
make
sudo make install

 次に nghttp2 を。

git clone https://github.com/tatsuhiro-t/nghttp2.git
cd ./nghttp2
autoreconf -i
automake
autoconf
./configure --enable-app
make
sudo make install

 とすると、/usr/local/bin 以下に h2load がインストールされる。

 あとは HostA から HTTP/2 で動作済の HostB に向けて h2load をぶち込む。

h2load -n 1000 -c 10 https://http2.example.com/
TLS Protocol: TLSv1.2
Cipher: ECDHE-RSA-AES128-GCM-SHA256
Application protocol: h2
..
(snip
..
finished in 1.23s, 810.23 req/s, 49.35MB/s
requests: 1000 total, 1000 started, 1000 done, 1000 succeeded, 0 failed, 0 errored, 0 timeout
status codes: 1000 2xx, 0 3xx, 0 4xx, 0 5xx
traffic: 63867490 bytes total, 269000 bytes headers (space savings 4.27%), 63499000 bytes data
                     min         max         mean         sd        +/- sd
time for request:     2.50ms     28.69ms     11.44ms      2.00ms    71.60%
time for connect:    15.48ms     55.30ms     47.41ms     12.76ms    80.00%
time to 1st byte:    39.77ms     59.46ms     55.54ms      5.56ms    90.00%
req/s (client)  :      81.05       90.46       83.94        2.92    90.00%

 試しに HostB から HTTP/1.1 でしか動作しない HostA に h2load をぶち込んでみると、勝手にフォールバックして HTTP/1.1 になってくれる。便利。

h2load -n 1000 -c 10 https://http11.example.com/
starting benchmark...
spawning thread #0: 10 total client(s). 1000 total requests
TLS Protocol: TLSv1.2
Cipher: ECDHE-RSA-AES128-GCM-SHA256
No protocol negotiated. Fallback behaviour may be activated
Server does not support NPN/ALPN. Falling back to HTTP/1.1.
Application protocol: http/1.1
..
(snip
..
finished in 1.03s, 966.44 req/s, 58.99MB/s
requests: 1000 total, 1000 started, 1000 done, 1000 succeeded, 0 failed, 0 errored, 0 timeout
status codes: 1000 2xx, 0 3xx, 0 4xx, 0 5xx
traffic: 64007000 bytes total, 591000 bytes headers (space savings 0.00%), 63280000 bytes data
                     min         max         mean         sd        +/- sd
time for request:     2.92ms     37.41ms      9.68ms      3.98ms    76.80%
time for connect:    30.20ms     52.20ms     45.40ms      5.65ms    80.00%
time to 1st byte:    46.78ms     68.77ms     57.30ms      7.08ms    50.00%
req/s (client)  :      96.71      100.45       98.69        1.13    70.00%
著者プロフィール
ぶっち

本格的に PC へ触れ始めてたのは 1990 年位から。
興味は PC 全般。OS は Windows と Linux などを嗜む。
プログラマやネットワークエンジニアを経てフリーに活動している 2 児の父な 40 代半ばのおじさんです。

ぶっちをフォローする

コメント

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.