Codele / System design
Rate limiting
One caller sending thousands of requests can swamp a service for everyone. A rate limit hands out tokens, and no token means “wait”.
- Rate limiting caps how fast one caller can use a service, so one caller cannot slow it down for everyone.
- A token bucket holds up to a set number of tokens. Each request spends one.
- Tokens drip back at a steady speed, but the bucket never holds more than its size.
- No token means the request is refused with status 429 Too Many Requests. The caller should wait and try again.
- A bigger bucket allows a bigger burst. The drip speed sets the long-run rate.
Loading the playable lesson…