Step 1 · The pattern
A limit at the door
Every request passes a limiter first. The busy client in the middle may make 8 requests per window and sends twice that. Its first eight are served. The rest are refused at the door and never reach the service.
- request
- served
- refused
In short
429 and Retry-After: how it works and how it breaks
A rate limiter's refusal is part of your API, because clients act on it. If the limiter drops the request or answers with a generic server error, the client cannot tell a limit from a fault, so it does what it does for faults: it retries at once. The refused traffic returns several times over, the limiter spends its effort refusing the same requests again, and other users wait behind them. A 429 Too Many Requests says something precise: this client is over its limit and should slow down. A Retry-After header adds when asking again can succeed, as a number of seconds or a date. A well-behaved client keeps the request, waits that long and sends it once. The limiter then sees roughly the real demand, and every request is served in the end. Because a limiter refuses before any work is done, repeating the request later is safe.
How this comes up in interviews
"Your rate limiter refuses a request. What should the response contain, and why does that matter to the rest of the system?"
Then they ask
- What goes wrong if the limiter answers with a generic 500 or 503, or drops the request?
- Retry-After can be a number of seconds or a date. Which do you send, and why?
- Clients assume a 429 means the request was not processed. How do you make sure that is true?
A strong answer covers
- A limiter's refusal is part of the API, because clients act on it.
- A generic server error looks like a fault, so clients retry at once and the refused traffic returns several times over.
- 429 Too Many Requests says this client is over its limit, and Retry-After says when asking again can succeed.
- A well-behaved client keeps the request, waits that long and sends it once, so the limiter sees roughly the real demand.
- Refuse before any work is done, so that repeating the request later is safe.
Points to cover, not a script. Say them in your own words and tie them to a system you have worked on.
On one page: the track cheat sheet.
Sources: RFC 6585: Additional HTTP Status Codes (429 Too Many Requests) ↗ · RFC 9110: HTTP Semantics (Retry-After) ↗ · IETF Internet-Draft: RateLimit header fields for HTTP ↗ · nginx: limit_req_status ↗ · Report a problem
Diagrams are our own simulations: the timings, rates and counts in them are illustrative, not measurements. Captions are original wording.