我的ApacheBench负载测试结果中按长度失败的请求 [英] Failed requests by length in my ApacheBench load test result
问题描述
我有一个使用PHP的网站,Lighttpd.它还在Centos 5上使用MySQL.我已经使用Apache Bench(ab)在下面的代码中测试了我的PHP.这导致了一些错误(失败的请求),表明长度超出了正常范围.我绝对确定我的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)
使用-v 2
参数(表示详细级别2)运行ab
.这将转储响应头.如果您的请求未使用分块编码,则将看到"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
选项来查看对单个请求的压缩和不压缩的响应标头.
I have a website in PHP, Lighttpd. It uses also MySQL on Centos 5. I've tested my PHP with code below with Apache Bench (ab). It resulted in some errors (Failed Requests) indicating other length than normal. I'm absolutely sure that my PHP result should always have the same exact length. I've reviewed my Lighttpd and MySQL logs and error logs and don't have any errors there.
Is there any way to check exactly what ab gets when result has other length or is there any other way to find out what is the cause or what is the "bad" result?
I need to know that because I need to have 100% good results.
-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)
Run ab
with the -v 2
parameter, meaning verbosity level 2. This will dump the response headers. If your requests are not using chunked encoding, you will see a "Content-Length" header indicating the size of each response.
gw:~$ ab -n 1 -v 2 "http://whatever.com/"
...
LOG: header received:
HTTP/1.0 200 OK
...
Content-Length: 1568399
If your responses use chunked encoding, then the length is not known until the transfer ends. Usually chunked encoding is only used for compressed responses, and ApacheBench doesn't do compression by default.
If it is compressing the responses for whatever reason that might explain it; the compressed length depends on the content.
You can also use curl -i
and the --compress
option to see the response headers to a single request with and without compression.
这篇关于我的ApacheBench负载测试结果中按长度失败的请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!