We recently switched to nginx and I was happy to see that rate limiting seems easy enough there. I set up the following limit for a particular zone:
limit_req_zone $binary_remote_addr zone=PHPUtilities:10m rate=60r/m;
I applied that zone to a location block with a burst of 20. That all seemed fine, but what I was surprised to see was that I would quickly get slowdowns where the server would refuse to respond for 5 seconds or so. It seems like nginx takes the 60 requests per minute and divides that down to 1 request per second. So if we loaded several scripts simultaneously, nginx would serve the first request right away and then delay the others.
I'd rather it behaved sort of like "ok they get a free 60 requests per minute. Only once they hit 60 will we begin limiting them, first by slowing down the next 20 requests (the burst). Everything after that will crap out until they stop requesting so much, or fall below the 60 per minute limit."
Is there a way to do that?
PS. I accidentally asked this question on Stack Overflow first, then realized it was more appropriate here. :(