27

PHPのウェブサイトLighttpdがあります。Centos 5でもMySQLを使用しています。以下のコードを使用して、Apache Bench(ab)を使用してPHPをテストしました。通常以外の長さを示すいくつかのエラー(Failed Requests)が発生しました。私のPHPの結果は常に同じ正確な長さである必要があると確信しています。LighttpdとMySQLのログとエラーログを確認しましたが、エラーはありません。

結果が他の長さであるときにabが何を取得するかを正確に確認する方法はありますか、または原因または「悪い」結果が何であるかを見つける他の方法はありますか?

100%良い結果が必要なので、それを知る必要があります。

-bash-3.2# ab -n 500 -c 200 http://domain.com/test/index.php
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright 2006 The Apache Software Foundation, http://www.apache.org/

Benchmarking domain.com (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Finished 500 requests


Server Software:        lighttpd/1.4.20
Server Hostname:        domain.com
Server Port:            80

Document Path:          /test/index.php
Document Length:        15673 bytes

Concurrency Level:      200
Time taken for tests:   0.375862 seconds
Complete requests:      500
Failed requests:        499
   (Connect: 0, Length: 499, Exceptions: 0)
Write errors:           0
Total transferred:      7920671 bytes
HTML transferred:       7837000 bytes
Requests per second:    1330.28 [#/sec] (mean)
Time per request:       150.345 [ms] (mean)
Time per request:       0.752 [ms] (mean, across all concurrent requests)
Transfer rate:          20579.36 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0   10   9.4      6      30
Processing:     0  113 133.5     16     342
Waiting:        0  111 134.3     12     341
Total:          0  123 138.9     16     370

Percentage of the requests served within a certain time (ms)
  50%     16
  66%    235
  75%    289
  80%    298
  90%    331
  95%    345
  98%    365
  99%    368
 100%    370 (longest request)
4

3 に答える 3

20

詳細レベル 2 を意味するパラメーターを指定して実行abします。これにより、応答ヘッダーがダンプされます。-v 2リクエストがチャンク エンコーディングを使用していない場合、各レスポンスのサイズを示す「Content-Length」ヘッダーが表示されます。

gw:~$ ab -n 1 -v 2 "http://whatever.com/"

...

LOG: header received:
HTTP/1.0 200 OK
...
Content-Length: 1568399

応答がチャンク エンコーディングを使用している場合、長さは転送が終了するまでわかりません。通常、チャンク エンコーディングは圧縮された応答にのみ使用され、ApacheBench はデフォルトでは圧縮を行いません。

それを説明する何らかの理由で応答を圧縮している場合圧縮された長さはコンテンツによって異なります。

オプションを使用curl -i--compressて、単一の要求に対する応答ヘッダーを圧縮あり/なしで表示することもできます。

于 2010-07-03T01:11:09.640 に答える
3

ab は、すべての応答が同じであると想定しています。最初の応答の content-length を確認し、それと他の応答を比較します。

マニュアルページから:

Document Length
  This is the size in bytes of the first successfully returned document. 
  If the document length changes during  testing,  the  response  is 
  considered an error.

したがって、最初のリクエストに次のデータが含まれている場合:

{"hostname":"nodecellar-1-dwfxd","serverip":"10.1.3.3"}

そして、次のものは次のとおりです。

{"hostname":"nodecellar-1-dwfxd","serverip":"10.1.3.30"}

出力が 1 文字長いため、ab は長さエラーで失敗します。

于 2016-06-29T11:57:30.657 に答える