为了做一些负载测试,出于我自己的好奇心,我在我的服务器上运行:
ab -kc 50 -t 200 http://localhost/index.php
这会在200秒内打开50个keep-alive连接,并向服务器发送index.php请求
在我的结果中,我得到:
Concurrency Level: 50
Time taken for tests: 200.007 seconds
Complete requests: 33106
Failed requests: 32951
(Connect: 0, Receive: 0, Length: 32951, Exceptions: 0)
Write errors: 0
Keep-Alive requests: 0
Total transferred: 1948268960 bytes
HTML transferred: 1938001392 bytes
Requests per second: 165.52 [#/sec] (mean)
Time per request: 302.071 [ms] (mean)
Time per request: 6.041 [ms] (mean, across all concurrent requests)
Transfer rate: 9512.69 [Kbytes/sec] received
请注意32951个“失败”请求。我想不出来。
当测试运行时,我可以从家里的电脑完美地访问我的网站,尽管页面底部的页面加载时间报告为0.5,而不是通常的0.02。然而,我从未遇到过失败的请求。
那么为什么AB报告一半的连接失败呢?在这种情况下"长度"是什么意思?