Unexpected result with limit_req module

flygoast flygoast at 126.com
Sun Sep 20 09:51:26 UTC 2015


Hi, all,


I use limit_req module to limit QPS to my upstream, conf like this:
http {
limit_req_zone $request_uri zone=req_one:10m rate=10000r/s;
server {
...
location / {
limit_req zone=req_one;
       }
}
}


I use benchmarking tool to stress on one url, but only about 1000 request. 


I checked source code, found that:
            ms = (ngx_msec_int_t) (now - lr->last);


            excess = lr->excess - ctx->rate * ngx_abs(ms) / 1000 + 1000;


            if (excess < 0) {
                excess = 0;
            }


            *ep = excess;


            if ((ngx_uint_t) excess > limit->burst) {
                return NGX_BUSY;
            }


At here, ms can be '0', so in a millisecond, only the first request can pass the checking. After I set burst value to (rate / 1000) in configuration file, the QPS result is expected.


I'm not sure whether this is a bug or It's my fault in configuration.


Thanks.







-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20150920/6d08319d/attachment.html>


More information about the nginx-devel mailing list