Reliability / 2 / 6
Rate limiting
One noisy client can slow an API down for everyone. How to cap each client fairly: windows, token buckets, 429 answers and a counter shared by all servers.
- 13 min
- Intermediate
- 12 steps
- Partner p95
- 2 400 ms
- Honest errors
- 9 %
- Over the limit
- 90 x
- request
- reply
- redelivery
- duplicate
- lost
- call: the reply returns on the same line
Numbers are a model scenario, not measurements
The real request
Script → APIRequest
GET /v1/products?page=8812 HTTP/1.12
Host: api.example.com
X-Api-Key1: hidden
Response
HTTP/1.1 200 OK
X-Response-Time3: 2380 ms
X-Api-Key· hidden — The script has a valid key. The requests are allowed, just far too many.page— Page 8812: nobody reads that far. It is a crawl, not a user.X-Response-Time— Even this request waited 2.4 s in a queue behind its own siblings.
What happens if…?
Put in your own numbers: the result and the formula update at once.
Tokens returned to the bucket per second: the long-term limit.
The largest burst that passes at once.
Requests per second one client sends.
A batch of requests arriving at once at a full bucket.
Result
- Burst passed
- 25
- Burst rejected
- 0
- Passed per second
- 10/s
- Rejected per second (429)
- 890/s
- Share rejected
- 98.9%
Working
burst: min(B, cap) = min(25, 30) = 25 → 0 × 429
steady: min(R, rate) = min(900, 10) = 10/s
429: 900 − 10 = 890/s = 98.9%A simplified teaching model: it shows direction and scale, not a benchmark.
Build it yourselfCheat sheetCompare lessons
Course: 74 lessons
01 Foundations
02 Scaling
03 Data & storage
04 Communication
05 Reliability
06 Architecture
07 Security
08 Shipping
09 Whole systems
10 Business processes
11 Case studies