2

I have a strange behavior my config looks something like this:

http {
    limit_req_zone $binary_remote_addr zone=nocachelimit:10m rate=120r/m;
}
...
location "/api" {
    {
        limit_req zone=nocachelimit burst=20;
    }
}

Regardless of what values i put into the rate, I even tried 1000r/s I keep getting log entries for "normal" users that say:

 [warn] 16526#0: *4661 delaying request, excess: 1.000, by zone "nocachelimit"

The typical usecase is a Pageload that does not fall into the zone + 4-5 Ajax requests that will should be limited to the zone.

What could be the cause for this kind of behavior.

2
  • Have you restarted nginx?
    – Alexey Ten
    Feb 5 '16 at 10:20
  • yes restart and reload
    – gries
    Feb 5 '16 at 10:42
2

The rate determines how fast requests are processed. If you set the rate to 120r/m, that means 1 request will get processed every 0.5 seconds.

If you get 5 requests all at once, it doesn't mean that they'll all go through. They'll get queued up (up to your burst size), and get processed sequentially, 1 every 0.5 seconds.

You're getting that warning because things are going into the queue and getting delayed. It does not mean that they're getting rejected.

If you don't want things getting delayed, then use the nodelay parameter:

location "/api" {
  limit_req zone=nocachelimit burst=20 nodelay;
}

For more details on exactly how this works, see https://www.nginx.com/blog/rate-limiting-nginx/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.