LoginSignup
67
70

More than 5 years have passed since last update.

Ab(Apache Bench)を使用した負荷テストのやり方

Last updated at Posted at 2014-02-24

Ab(Apache Bench)とは

Apacheで標準でついてくる負荷テストツール。単一ページに対しての負荷テストのみ実行可能であるため、あまり難しいことはできないが手軽に使える。

実行方法

一番簡単な実行方法

ab -n [総リクエスト数] -c [同時リクエスト数] [URL]

同時10接続で、100リクエスト発行するならこうなる。

ab -n 100 -c 10 http://localhost/test.php

Keep Aliveを有効にするには、-k をつける。

ab -n 100 -c 10 -k http://localhost/test.php

他にもいくつかオプションはあるが、基本はこの形。

実行結果の見方

実行するとこんな結果が戻ってくる。

[vagrant@localhost ~]$ ab -n 1000 -c 100 http://localhost/test.php

Benchmarking localhost (be patient).....done

Server Software:        Apache/2.2.15
Server Hostname:        localhost
Server Port:            80

Document Path:          /test.php
Document Length:        48 bytes

Concurrency Level:      100
Time taken for tests:   34.093 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      240000 bytes
HTML transferred:       48000 bytes
Requests per second:    29.33 [#/sec] (mean)
Time per request:       3409.323 [ms] (mean)
Time per request:       34.093 [ms] (mean, across all concurrent requests)
Transfer rate:          6.87 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1   1.7      1       7
Processing:  1006 3227 632.8   3020    4024
Waiting:     1001 3226 633.3   3018    4023
Total:       1008 3228 632.1   3022    4030

Percentage of the requests served within a certain time (ms)
  50%   3022
  66%   3025
  75%   3982
  80%   3984
  90%   3992
  95%   3997
  98%   4009
  99%   4016
 100%   4030 (longest request)

まずは、この2つの値を見て見る。

  • Failed Requests: 失敗したリクエスト数。これが発生している場合は、サーバが処理できる能力を超えている。
  • Requests per second:1秒あたりに処理したリクエスト数。

「Failed Requests」が0、「Request per second」がより大きい数値になるようにチューニングする。

67
70
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
67
70