RELIABILITY, SECURITY & CASE STUDIES · SUBTOPIC
Distributed Rate Limiting & Leaky Bucket
Coordinate limits across dozens of API gateway pods and smooth outbound bursts.
IntermediatePart of Rate Limiting & Throttling
Subtopics in Rate Limiting & Throttling (2)
In plain words
Leaky Bucket drips water out of a funnel at one steady speed even if someone dumps a whole pitcher in - great for protecting slow downstream APIs. Distributed rate limiting shares one Redis cluster so users can’t multiply their quota by hitting 10 gateways.
Think of it like…
Funnel dripping smoothly into a bottle (Leaky Bucket) + shared scoreboard across every stadium gate (Redis).
Loading interactive diagram
Loading interactive exercise
Theory & how it works
Fail-open vs. Fail-closed when Redis is unreachable
For normal API traffic, fail-open (allow requests or apply a loose local memory cap) so a Redis hiccup doesn’t take your whole product offline. For security-critical endpoints like /login or /otp/verify, fail-closed or enforce strict local IP limits to block credential-stuffing attacks.
Key points & practical guide
Summary checklist
- Leaky Bucket smooths bursty traffic into a constant outflow rate
- Rate limit by User/API-Key for authenticated routes, IP for anonymous routes
- Decide explicit fail-open vs. fail-closed behavior per endpoint
When to use it
- Protecting third-party webhooks/APIs with strict RPS caps and multi-node gateways
Watch out for
- Storing per-gateway counters in local RAM only - 20 gateways gives every attacker 20× the limit!
Quick check
Loading quiz