php - 在我的 ApacheBench 负载测试结果中按长度失败的请求

标签 php scalability lighttpd load-testing apachebench

我有一个 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 参数运行 ab,表示详细级别 2。这将转储响应 header 。如果您的请求未使用分 block 编码,您将看到一个指示每个响应大小的“Content-Length” header 。

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

...

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

如果您的响应使用分 block 编码,那么在传输结束之前长度是未知的。通常分 block 编码仅用于压缩响应,而 ApacheBench 默认不进行压缩。

如果它出于任何可能解释它的原因压缩响应;压缩长度取决于内容。

您还可以使用 curl -i--compress 选项来查看单个请求的响应 header 是否经过压缩。

关于php - 在我的 ApacheBench 负载测试结果中按长度失败的请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1512304/

相关文章:

php - Mysql查询查找2列的最小值和最大值,其中1列的最小值不能等于零

php - 使用 PHP 将数组插入 MySQL

repository - 在常见的 x86 硬件上水平扩展存储库

node.js + socket.io + redis 架构 - 水平服务器缩放套接字连接?

lighttpd 上的 apache .htaccess 文件

php - 自动分配 PDO 类型

ElasticSearch 分析查询

php - 如何在 lighttpd 中启用 mod 重写

ssl - Lighttpd:仅启用了 SSLv3,但使用了 TLSv1.2

php - 如何在Drupal中显示两个 block 中的一个 block ?