LoginSignup
3
2

More than 3 years have passed since last update.

h2loadで負荷試験を行う

Posted at

1.目的

PHPやpythonでWEBアプリを作成すると、レスポンスの性能が気になるところです。なので、ある程度の接続ユーザがアプリにアクセスする場合には、負荷試験は必須です。ベンチマークを計測ツールを使いたいと思います。

負荷試験のツールを検索していると、Apache Bench や wrkなどが有名どころのようですが、
h2load で HTTP/2.0 に対応した負荷試験を実施するの記事で、h2loadという便利そうなツールがあることを知りました。

この記事に従って負荷試験ができるか試したみた件を投稿します。

2.環境

カテゴリ バージョンなど
platform windows 10 64bit home
os ubuntu18.04 (wsl)

今回の環境は、windows10のWSL(ubuntu)にh2loadをインストールしました。

3.インストール

sudo apt-get update -y
sudo apt-get install -y nghttp2

4.負荷試験

以下は、python + responder + sqlalchemy(postgresql)のユーザマスタ(4件登録済み)の全件検索を、ベンチマークしています。

h2load -p http/1.1  -c 100 -n 1000 http://localhost:5042/users/findall
starting benchmark...
spawning thread #0: 100 total client(s). 1000 total requests
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 4.64s, 215.31 req/s, 682.95KB/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: 3.10MB (3248000) total, 62.50KB (64000) headers (space savings 0.00%), 3.01MB (3153000) data
                     min         max         mean         sd        +/- sd
time for request:   258.96ms    530.11ms    450.46ms     49.15ms    77.20%
time for connect:     2.89ms     29.32ms     16.05ms      7.52ms    61.00%
time to 1st byte:   374.88ms    492.22ms    428.80ms     35.73ms    55.00%
req/s           :       2.15        2.31        2.21        0.06    71.00%

参考サイトにもありますが、h2loadのオプションを掲載しておきます。

オプション 意味 指定可能な値
-n 総リクエスト数。 リクエスト数がこの値に到達するまで、リクエストし続ける 整数を指定
-c クライアント数。 並行して実行するクライアントの数 整数を指定
-m クライアント当たりの、最大ストリーム並列数 整数を指定
-p プロトコル。 通常は HTTP バージョンを自動調整するが、明示的に特定バージョン指定したい場合に利用する h2c や http/1.1

以上

3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2