Apache Webサーバーの負荷テスト(Centos6で実行)[閉じる]

Apache Webサーバーの負荷テスト(Centos6で実行)[閉じる]

接続が失われたりタイムアウトしたりせずにWebサーバー(Apache)設定が処理できる要求の数を簡単にテストする方法は?

単純なbashスクリプトはありますか?それとも複雑なストレステストツールを使用する必要がありますか?

ベストアンサー1

abテストにはパッケージに含まれているソフトウェアを使用できますapache2-utils。例:

ab -r -n 100 -c 10 -k -H "Accept-Encoding: gzip, deflate" http://mysite.mydomain.com/
  • -r:ソケットエラーによるシャットダウンを防ぎます。
  • -n:実行する要求の数。
  • -c:同時に実行される複数の要求の数。
  • -k:HTTP KeepAliveを有効にします。これは、Httpセッションごとに複数の要求を実行することを意味します。
  • -H:カスタムヘッダ。これはサイトの構成方法によって大きく異なります。

以下は、インデックスページ(php)のみを持つ簡単なサイトで行ったテストの結果です。

# ab -r -n 200 -c 20 -k -H "Accept-Encoding: gzip, deflate" http://intranet.example.com/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking intranet.example.com (be patient)
Completed 100 requests
Completed 200 requests
Finished 200 requests


Server Software:        Apache/2.2.15
Server Hostname:        intranet.example.com
Server Port:            80

Document Path:          /
Document Length:        10276 bytes

Concurrency Level:      20
Time taken for tests:   38.344 seconds
Complete requests:      200
Failed requests:        0
Write errors:           0
Keep-Alive requests:    0
Total transferred:      2132800 bytes
HTML transferred:       2055200 bytes
Requests per second:    5.22 [#/sec] (mean)
Time per request:       3834.421 [ms] (mean)
Time per request:       191.721 [ms] (mean, across all concurrent requests)
Transfer rate:          54.32 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.1      0       1
Processing:  2869 3813 383.1   3649    5205
Waiting:     2868 3781 380.4   3613    5161
Total:       2869 3814 383.1   3650    5205

Percentage of the requests served within a certain time (ms)
  50%   3650
  66%   3763
  75%   3971
  80%   4318
  90%   4451
  95%   4530
  98%   4634
  99%   5093
 100%   5205 (longest request)

ただし、httpdサービスに過負荷がかかっていないことを確認し、サーバーに大きな影響を与えるようにすべてのパラメータを増やすには、テスト間に少し時間を費やす必要があります。私が知る限り、この出力を評価し、動的に測定されたパラメータのパフォーマンスを向上させるツールはありません。

リンク:

おすすめ記事