Skip to content

Instantly share code, notes, and snippets.

@Integralist
Created February 12, 2020 17:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Integralist/c13c30dcad137e93b38f7f8e0581945a to your computer and use it in GitHub Desktop.
Save Integralist/c13c30dcad137e93b38f7f8e0581945a to your computer and use it in GitHub Desktop.
[nginx rate limiting is weird] #nginx #ratelimit

nginx rate limiting is weird

it takes input in requests per second

but that’s not how it rate limits

instead it divides your limit into tenth of a second chunks

so a rate limit of 10 req/s is actually 1 req / 0.1 s

which means if you get 2 requests within 0.1 s, the second one will be rejected

the best way to mitigate this is to allow a burst (this is what we do on webapp_waf) where you allow a burst of e.g. 10 reqs - meaning the first 10 requests wont be limited, but then if that rate is sustained future ones will be limited based on the tenth of a second bucketing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment