bumingchun commented on PR #1763:
URL: https://github.com/apache/incubator-brpc/pull/1763#issuecomment-1132354473
> > > 新代码计算expected_time的方式为(start_time + n *
interval),其中start_time是发第一个请求的时间,n是请求个数,并不是依赖上一次的访问时延,程序启动的时间就决定了每个请求发送的expected_time,这种实现方式中expected_time不受抖动影响。旧的实现方式中抖动是会累计的,本次抖动会影响一个窗口过后请求的发送时间,并一直传递,所以我才有“随程序运行时间变长,抖动出现的次数越来越多,发送地请求会越来越不均匀”的结论。
> >
> >
> >
新方法中一旦某段时间发送特别慢(如线程不被调度了),恢复后实际时间就会远大于预期时间,之后会不做任何sleep以最大速率连续发送,直到预期时间追上?这个其实timeq针对的问题,只受之前一段请求的影响。
>
> 有个改进的方法,每隔n个请求,重置expected_time = end_time + interval
或者限制expected_time不能落后当前时间太多(X)
>
> ```c++
> if (expected_time < end_time - X) {
> expected_time = end_time - X;
> }
> ```
这个思路可以,相当于是我的实现方式和jmeter实现方式的折中。即可以尽量保证qps等于预设值,也可以避免大量请求以最高速率发送。
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]