Welcome! Log In Create A New Profile

Advanced

Unexpected result with limit_req module

September 20, 2015 05:52AM
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.







_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

Unexpected result with limit_req module

flygoast 818 September 20, 2015 05:52AM

Re: Unexpected result with limit_req module

Maxim Dounin 537 September 21, 2015 09:28AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 145
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready