switch to ms resolution for rate limiting
Maxim Dounin
mdounin at mdounin.ru
Wed Nov 30 03:41:59 UTC 2022
Hello!
On Mon, Nov 28, 2022 at 06:40:33AM +0100, Jérôme Loyet wrote:
> Hello,
>
> I'm using rate limiting within the stream module. While it works great
> for long connections it does not work on request smaller than the rate
> limite size for 1 second. I set up a 1gbps rate limit (limit_rate
> 125m) and request smaller than 125M or not limited. This is a normal
> behavioir as the rate limiting is done with a second precision. This
> patch change second precision to millisecond precision. From my first
> tests (still on going) it seems to works better.
>
> What guys do you think about this patch ?
A while ago a similar patch was considered for both stream and
http, though there is an open question on how to handle
long-running requests on 32-bit platforms (where ngx_msec_t will
overflow after ~48 days). With the naive approach, which is also
seen in your patch, all traffic on a such connection is likely to
completely stop after the overflow, which does not seem to be a
good outcome.
--
Maxim Dounin
http://mdounin.ru/
More information about the nginx-devel
mailing list