current RPS is not accurate
debugtalk opened this issue · comments
debugtalk commented
Describe the bug
When running in standalone mode, the ConsoleOutput will print each (method, name) group's current RPS. And I found that the data is not accurate. The report interval is 3s, the requests number of get with params
is 20, the rps should be 20/3=6.67
, which is much bigger than the actual 5.
Current time: 2021/12/01 12:06:26, Users: 10, Total RPS: 15, Total Fail Ratio: 0.0%
+--------------+-----------------+------------+---------+--------+---------+-----+------+--------------+------------+-------------+
| TYPE | NAME | # REQUESTS | # FAILS | MEDIAN | AVERAGE | MIN | MAX | CONTENT SIZE | # REQS/SEC | # FAILS/SEC |
+--------------+-----------------+------------+---------+--------+---------+-----+------+--------------+------------+-------------+
| request-GET | get with params | 20 | 0 | 970 | 977.15 | 954 | 1089 | 300 | 5 | 0 |
| request-POST | post json data | 20 | 0 | 250 | 244.70 | 238 | 251 | 420 | 5 | 0 |
| request-POST | post form data | 20 | 0 | 250 | 245.20 | 240 | 253 | 441 | 5 | 0 |
+--------------+-----------------+------------+---------+--------+---------+-----+------+--------------+------------+-------------+
This issue maybe resulted from the algorithm of calculating current rps. As the keys of numReqsPerSecond
is timestamps, while mostly the interval may span 4 seconds, e.g. starts from 0.5s and ends at 3.5s.
func getCurrentRps(numRequests int64, numReqsPerSecond map[int64]int64) (currentRps int64) {
currentRps = int64(0)
numReqsPerSecondLength := int64(len(numReqsPerSecond))
if numReqsPerSecondLength != 0 {
currentRps = numRequests / numReqsPerSecondLength
}
return currentRps
}
orange commented
看起来可以把 slaveReportInterval 传给 output ,用于计算 CurrentRps 。不知是否可以提pr
myzhan commented
@MyNextWeekend 不太清楚你要怎么实现,可以先提 PR 看看。