我用 ab 进行压测,设置请求总数 1000,但压测完为啥 Complete requests+Failed requests 不等于 1000 呢?

2023-04-16 00:38:22 +08:00
 yuann72

-n 参数设了 1000, 但实际只请求了 300 多个, 是我哪里弄错了吗?

所使用的命令:

ab -n 1000 -c 100 -t 30 -p "/playground/1" -T "multipart/form-data; boundary=96180d74-ac90-4fcf-9383-9ea9d147d94b" -H "Authorization: Bearer xxx" "http://xxxx.com"

压测结果:

Benchmarking xxx.com (be patient)
Finished 319 requests


Server Software:
Server Hostname:        xxx.com
Server Port:            80

Document Path:          
Document Length:        255 bytes

Concurrency Level:      100
Time taken for tests:   30.034 seconds
Complete requests:      319
Failed requests:        14
   (Connect: 0, Receive: 0, Length: 14, Exceptions: 0)
Non-2xx responses:      14
Total transferred:      167841 bytes
Total body sent:        27554560
HTML transferred:       77775 bytes
Requests per second:    10.62 [#/sec] (mean)
Time per request:       9414.936 [ms] (mean)
Time per request:       94.149 [ms] (mean, across all concurrent requests)
Transfer rate:          5.46 [Kbytes/sec] received
                        895.95 kb/s sent
                        901.41 kb/s total

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        7    9   1.0      8      12
Processing:   477 7536 3093.2   7573   17061
Waiting:      475 7536 3093.2   7573   17061
Total:        486 7545 3093.2   7581   17070
WARNING: The median and mean for the initial connection time are not within a normal deviation
        These results are probably not that reliable.

Percentage of the requests served within a certain time (ms)
  50%   7578
  66%   8615
  75%   9234
  80%   9752
  90%  11527
  95%  12358
  98%  15382
  99%  15992
 100%  17070 (longest request)
703 次点击
所在节点    问与答
2 条回复
faceair
2023-04-16 01:17:06 +08:00
From GPT-4:

在这个情况下,由于你设置了 -t 30 参数,这意味着 ab 压测工具在 30 秒后会停止发送请求。因此,在压测过程中,只有在 30 秒内完成的请求会被记录。在你的压测结果中,只有 319 个请求在 30 秒内完成,因此 Complete requests 和 Failed requests 的和不等于 1000 。

为了确保你的 1000 个请求都被发送和记录,你可以将 -t 参数去掉,或者将其设置为一个足够长的时间,以便所有请求都能在这段时间内完成。

同时,请注意,如果你想要发送更多的请求,也可以适当增加并发级别(-c 参数)。但请注意,增加并发级别可能会增加服务器的负载,所以需要根据实际情况进行调整。
yuann72
2023-04-16 01:35:47 +08:00
@faceair #1 好吧, 确实是这样😂

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/932837

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX