How to control the total requests in Ngnix

Maxim Dounin mdounin at
Fri Dec 1 13:46:02 UTC 2017


On Fri, Dec 01, 2017 at 11:18:06AM +0800, tongshushan at wrote:

> I configured as below:
> limit_req_zone "all" zone=all:100m rate=2000r/s;
> limit_req zone=all burst=100 nodelay;
> but when testing,I use tool to send the request at: Qps:486.1(not reach 2000)  I got the many many 503 error,and the error info as below:
>  2017/12/01 11:08:29 [error] 26592#37196: *15466 limiting requests, excess: 101.000 by zone "all", client:, server: localhost, request: "GET /private/rush2purchase/inventory/aquire?productId=product1 HTTP/1.1", host: "localhost"
> Why excess: 101.000? I set it as 2000r/s ?

You've configured "burst=100", and nginx starts to reject requests 
when the accumulated number of requests (excess) exceeds 
the configured burst size.

In short, the algorithm works as follows: every request increments 
excess by 1, and decrements it according to the rate configured.  If 
the resulting value is greater than burst, the request is 
rejected.   You can read more about the algorithm used in 
Wikipedia, see
Maxim Dounin

More information about the nginx mailing list