ITPub博客

首页 > IT职业 > IT生活 > 压力测试工具ab的两个Time per request 参数含义和区别

压力测试工具ab的两个Time per request 参数含义和区别

IT生活 作者:rorog 时间:2021-09-09 09:05:37 0 删除 编辑

“老师,您好,我的问题如下:
关于ab测试结果中time per request 有两个展示项:
不过网上对这个参数的解释参差不齐,希望老师可以帮忙解惑下,有没有比较浅显的例子呢?”

有同学问题我这个问题,希望再详细点解释下:

1. 首先,介绍ab工具中,会出现两个Time per request ,如下:

$ ab -n 10 -c3 http:///
This is ApacheBench, Version 2.3
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking (be patient).....done

Server Software: nginx/1.4.6
Server Hostname:
Server Port: 80

Document Path: /
Document Length: 0 bytes

Concurrency Level: 3
Time taken for tests: 1.093 seconds
Complete requests: 10
Failed requests: 0
Non-2xx responses: 10
Total transferred: 2300 bytes
HTML transferred: 0 bytes
Requests per second: 9.15 [#/sec] (mean)
Time per request: 328.016 [ms] (mean) //第一个
Time per request: 109.339 [ms] (mean, across all concurrent requests) //第二个
Transfer rate: 2.05 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 127 134 4.6 136 139
Processing: 132 140 6.0 139 149
Waiting: 132 139 5.9 139 147
Total: 259 274 9.2 276 285

Percentage of the requests served within a certain time (ms)
50% 276
66% 278
75% 282
80% 283
90% 285
95% 285
98% 285
99% 285
100% 285 (longest request)

2. 先说下第二个数值是怎么来的?
我们会发现第二个Time per request时间会短很多,对吧,首先我们需要了解Time taken for tests,它表示请求的总时间。上面的演示中,请求的总时间为:1093ms
(第二个)Time per request = Time taken for tests / Complete requests
那么为 1093ms/10 =109.339 [ms]

3.那么第一个Time per request是什么意思呢?
其实主要的区别在请求的时间上,第一个Time per request会计算每一个请求的请求和结束时间,注意区别在计算统计每一个请求。
举个例子:
我们并发请求3个,分别每个请求的时间为30ms、40ms 、50ms ,总共并发完成的时间为90ms,那么:
(第二个)Time per request = 90ms /3 = 30ms
(第一个) Time per request = (30ms + 40ms + 50ms) /3 = 40ms

这么描述,大家应该好明白吧,两个时间都可以看出每一次请求的耗时,只是分析的维度不一样,第一个的总共时间是累计的每一次请求的时间和。

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/2976/viewspace-2799321/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2019-09-12

  • 博文量
    90
  • 访问量
    576