Hello,
I am trying to understand the openresty rate limit based on the nginx example given below.
limit_req_zone $binary_remote_addr zone= blitz:10m rate=5r/s;
location /search/ {
limit_req zone= blitz burst=1;
}
Here my understanding is that nginx will allow upto 5 request before delaying and 6 requests before rejecting it. Is it correct?
In my test, I am sending 10 requests in a loop and seeing 1 delayed and 8 rejected.
delaying request, excess: 0.995, by zone "blitz"
limiting requests, excess: 1.900 by zone "blitz"
If I change the nginx code in https://github.com/nginx/nginx/blob/master/src/http/modules/ngx_http_limit_req_module.c#L412 from
if ((ngx_uint_t) excess > limit->burst) to
if ((ngx_uint_t) excess > (limit->burst + ctx->rate))
It works as I described my expectations. Is my understanding incorrect or there is a bug in the code?