V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
yuann72
V2EX  ›  问与答

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

  •  
  •   yuann72 · 2023-04-16 00:38:22 +08:00 · 685 次点击
    这是一个创建于 376 天前的主题,其中的信息可能已经有所发展或是发生改变。

    -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)
    
    2 条回复    2023-04-16 01:35:47 +08:00
    faceair
        1
    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
        2
    yuann72  
    OP
       2023-04-16 01:35:47 +08:00
    @faceair #1 好吧, 确实是这样😂
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2476 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 16:05 · PVG 00:05 · LAX 09:05 · JFK 12:05
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.