nginx’s rate limiter has three settings that change its behavior completely: burst, nodelay and delay. Their descriptions are short, and the difference between them is easiest to understand by watching what happens to the same ten requests arriving at once. Below, nginx 1.24 on Ubuntu 24.04 was set up with five locations, each limited to one request per second with a different combination of options, and hit with ten simultaneous curl requests per location. Each result lists every request’s status code and how long it waited.
How limit_req works
Two directives
The nginx documentation describes the module as limiting the request processing rate per a defined key, in particular the rate of requests from a single IP address, using “the leaky bucket” method. Two directives are needed. limit_req_zone goes in the http block and defines the key, a shared memory area and the rate:
limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;
limit_req goes in a server or location and applies it:
location /search/ {
limit_req zone=one burst=5;
}
The key and the memory
$binary_remote_addr makes the limit per client IP address. The documentation explains why it is used in place of $remote_addr: its size is always 4 bytes for IPv4 and 16 for IPv6, and each stored state takes 64 bytes on 32-bit systems or 128 on 64-bit ones. One megabyte of zone holds about 16,000 states of 64 bytes or 8,000 of 128 bytes, so the 10m in the example tracks roughly 80,000 clients on a 64-bit server. When the zone fills, the least recently used state is dropped.
Rates below one per second
Rates are given in requests per second. For slower limits the documentation switches units: half a request per second is written 30r/m.

The test
Five locations
Each location got its own zone, all at rate=1r/s, so that one test could not leave traffic in another’s bucket:
| Location | Setting |
|---|---|
/noburst/ |
limit_req zone=z1; |
/burst/ |
limit_req zone=z2 burst=5; |
/nodelay/ |
limit_req zone=z3 burst=5 nodelay; |
/delay2/ |
limit_req zone=z4 burst=5 delay=2; |
/four29/ |
limit_req zone=z5 burst=5 nodelay; limit_req_status 429; |
Ten curl requests were started at the same moment against each one.
No burst: one gets through
/noburst/ 1 × 200, 9 × 503, all answered within 0.1 s
With no burst, the documentation says the maximum burst size is zero. One request per second is allowed; ten at once means one succeeds and nine are refused immediately. For anything a browser loads in parallel, a page with images or a single-page app making several API calls, this is far too strict.
burst: a queue
The default behavior
/burst/ 200@0.0s 200@1.0s 200@2.0s 200@3.0s 200@4.0s 200@5.0s, 4 × 503@0.0s
Six requests succeeded and four were refused. The six were not served together. The first was answered immediately, and the other five waited 1, 2, 3, 4 and 5 seconds, one per second, exactly the configured rate. The documentation describes this: when the rate is exceeded, processing is delayed such that requests are processed at a defined rate, and excess requests are delayed until their number passes the burst size, at which point they are refused with an error.
So burst=5 is a queue of five. It protects the backend perfectly, which never sees more than one request per second. It is also slow for the client: the sixth request in this test waited five seconds for a response that took milliseconds to produce.
The error log recorded the queuing at warning level: delaying request, excess: 0.998, by zone "z2".

nodelay: the burst served at once
Same counts, no waiting
/nodelay/ 6 × 200, 4 × 503, all answered within 0.1 s
The same six succeeded and the same four were refused, but nobody waited. The documentation’s line for this case: if delaying excess requests is not wanted, use the nodelay parameter.
The bucket still empties at the configured rate
nodelay does not raise the rate. It serves the burst immediately, but the slots it used still free up at one per second. The test showed it: the same /nodelay/ location, hit again with ten requests a few seconds after the first round, accepted only four. After six more seconds it accepted six again. A client that keeps firing bursts gets its first one free and then settles at the real rate.
For most websites, burst with nodelay is the useful combination: occasional clusters of requests from normal page loads go straight through, while sustained floods are cut to the configured rate.
delay: part immediate, part queued
The delay parameter, added in nginx 1.15.7, sets the point at which excess requests start being delayed. With burst=5 delay=2:
/delay2/ 200@0.0s ×3, 200@1.0s, 200@2.0s, 200@3.0s, 4 × 503@0.0s
Three requests went through immediately, the first one plus two from the burst, and the remaining three burst requests were spaced at one per second. Four were refused, as before. It is a compromise between the two: small clusters are fast, larger ones are smoothed. A setting like this suits an API whose clients normally send two or three calls together, but occasionally loop.
All three side by side
| Setting | Accepted | Refused | Slowest accepted request |
|---|---|---|---|
| (no burst) | 1 | 9 | 0.0 s |
burst=5 |
6 | 4 | 5.0 s |
burst=5 nodelay |
6 | 4 | 0.0 s |
burst=5 delay=2 |
6 | 4 | 3.0 s |
The number accepted depends only on burst. The other two options change when they are answered.
503 or 429
Choosing the status code
Refused requests get a 503 by default. The documentation lists limit_req_status with that default and lets it be changed. The /four29/ test with limit_req_status 429; returned the same split, six 200s and four refusals, but the refusals came back as 429.
429 is the status for “too many requests,” and well-behaved clients and crawlers can treat it as an instruction to slow down. A 503 reads as “the service is unavailable,” which is less accurate for a limit and can show up as an outage in monitoring.
Testing before enforcing
Two more directives help roll a limit out safely. limit_req_dry_run on, available since nginx 1.17.1, counts excess requests in the zone without actually limiting them. limit_req_log_level sets the severity of the log lines; the documentation notes that delays are logged one level below refusals. Running a new limit in dry-run mode for a day, then reading the error log, shows who would have been limited before anyone actually is.

Seeing the limiter’s decision per request
$limit_req_status in the access log
The error log only records refusals and delays. To see every request’s outcome, the documentation provides a variable, $limit_req_status, available since nginx 1.17.6, which holds the result for the current request: PASSED, DELAYED, REJECTED, and the dry-run versions of the last two. Added to a custom log format:
log_format rl "$status $limit_req_status $request_time $uri";
access_log /var/log/nginx/rl.log rl;
A repeat of three of the tests produced this, counted by line:
1 200 PASSED 0.000 /burst/
5 200 DELAYED 1.001 to 4.993 /burst/
4 503 REJECTED 0.000 /burst/
6 200 PASSED 0.000 /nodelay/
4 503 REJECTED 0.000 /nodelay/
6 200 PASSED 0.000 /four29/
4 429 REJECTED 0.000 /four29/
Two things stand out. Under nodelay, the burst requests are logged as PASSED, not DELAYED, because they were not held back at all; only the bucket counter knows they were excess. And the DELAYED lines carry the waiting time directly in $request_time, 1.0 to 5.0 seconds, which is the cost the client paid. A day of these lines answers the practical question before a limit goes live: how many real visitors would be delayed or refused, and for how long.
Layering limits
Per client and per site
Several limit_req directives can apply at once. The documentation’s own example combines a per-IP limit with a limit on the whole virtual server:
limit_req_zone $binary_remote_addr zone=perip:10m rate=1r/s;
limit_req_zone $server_name zone=perserver:10m rate=10r/s;
server {
limit_req zone=perip burst=5 nodelay;
limit_req zone=perserver burst=10;
}
Each client is held to one request per second, and the server as a whole to ten, however many clients there are.
The inheritance trap
The same section ends with a rule that catches configurations out: the directives are inherited from the previous level if and only if there are no limit_req directives defined on the current level. A server-wide limit plus one extra limit_req inside a location means that location loses the server-wide limit entirely, unless it is repeated there.
Behind a proxy
One more caution applies to the key. Behind a load balancer or CDN, every request arrives from the proxy’s address, and $binary_remote_addr puts every visitor into one bucket. The client’s real address has to be restored first, with nginx’s real IP module, or the limit will throttle the whole site as a single user.
Sources
- nginx documentation, “Module ngx_http_limit_req_module”: https://nginx.org/en/docs/http/ngx_http_limit_req_module.html
