# web鯖パフォーマンステスト ###### tags: `その他` ## 利用するテストツール **Autobench** web serverの自動ベンチマーキングツール # 導入 ## httperfの導入 ```shell= % sudo wget http://httperf.googlecode.com/files/httperf-0.9.0.tar.gz Password: --2021-04-07 11:10:30-- http://httperf.googlecode.com/files/httperf-0.9.0.tar.gz httperf.googlecode.com (httperf.googlecode.com) をDNSに問いあわせています... 64.233.189.82 httperf.googlecode.com (httperf.googlecode.com)|64.233.189.82|:80 に接続しています... 接続しました。 HTTP による接続要求を送信しました、応答を待っています... 404 Not Found 2021-04-07 11:10:31 エラー 404: Not Found。 ``` 代々案(Homebrew) ```shell= % brew install httperf ``` ## Autobenchの導入 ```shell= % brew install autobench ``` ## 利用方法 **構文** **`autobench [OPTIONS]...`** **OPTIONS** **`--file filename`** ベンチマークの結果を標準出力の代わりに出力するファイルを指定する(.csv/.tsv) **`--high_rate hrate`** テストの最後における1秒間あたりのコネクション数 **`--low_rate lrate`** テストの最初における1秒間あたりのコネクション数 **`--rate_step step`** テストあたりのコネクション増加数(lrateからhrateまで) **`--host1 hostname`** テスト対象のサーバのFQDN **`--port2 port`** host1のサーバのポート番号 **`--num_conn nconn`** コネクションの総数 **`--num_call call`** 一つのコネクションあたりのリクエスト数 **`--single_host`** 一つのサーバだけをテストする際に付ける **`--timeout time`** タイムアウトと判定する秒数 ## 試行 Dockerで立てたwebサーバに対して、ベンチマークを実行する。 ### Requirement - Docker (Docker version 20.10.5で検証済み) - Autobench --- 1. localhost:8080にnginxサーバを立てる ```shell= % docker run --name nginx_test -d -p 8080:80 nginx ``` 2. ベンチマークテストを行う ```shell= autobench --single_host --host1 localhost --port1 8080 --low_rate 20 --high_rate 50 --rate_step 10 --num_conn 140 --num_call 5 --timeout 10 --file ./result.csv ``` 上記のコマンドでは、単一ホスト(localhost:8080)に対して、コネクション数を20から50まで10ずつ増やしながらテストを行った。 timeoutは10秒, 一つのコネクションあたりのリクエスト数は5とした。 3. 結果の確認 ./result.csv ```csv dem_req_rate req_rate_localhost con_rate_localhost min_rep_rate_localhost avg_rep_rate_localhost max_rep_rate_localhost stddev_rep_rate_localhost resp_time_localhost net_io_localhost errors_localhost 100 100.6 20.1 100.0 100.0 100.0 0.0 1.5 89.6 0 150 150.8 30.2 0.0 0.0 0.0 0.0 1.4 134.3 0 200 201.0 40.2 0.0 0.0 0.0 0.0 1.4 179.0 0 250 250.8 50.2 0.0 0.0 0.0 0.0 1.4 223.4 0 ``` 以上 ## 結果の読み方 **`dem_req_rate`** 1秒あたりの接続数 **`req_rate`** 1秒あたりのリクエスト数 **`con_rate`** 1秒あたりのコネクション数 **`rep_rate`** 1秒あたりのリプライ数 **`stddev_rep_rate`** リプライの標準偏差 **`resp_time`** レスポンスタイムの平均(ms) **`net_io`** 通信速度 **`errors`** エラー率