System Design · Senior · Question 16 of 75
How do you implement rate limiting when the API runs on 20 servers?
- ✓Correct answer: Keep counters in shared fast storage (Redis) or at the gateway
- 2Count limits on each server independently - the result is the same
- 3Limit requests only in the browser with JavaScript
Explanation
Local counters give a limit ×20 and depend on load balancing. Shared storage with atomic operations (or a limiter at the API gateway/CDN) gives a global limit. Client-side limits are easily bypassed.