25. Rate Limiting
Interview questions
Interview questions (with the counter-questions you'll get)
Q1. Design a rate limiter.
They're testing: the classic question, end to end.
Think about your answer first, then open it.
Q2. Compare token bucket, leaky bucket, fixed window, sliding log and sliding window counter.
They're testing: algorithm knowledge.
Think about your answer first, then open it.
Q3. How do you rate limit across many servers?
They're testing: distributed state.
Think about your answer first, then open it.
Q4. Fail open or fail closed when the rate limiter's store is down?
They're testing: judgement under failure.
Think about your answer first, then open it.
Q5. What should the API return when a client is rate limited?
They're testing: client experience.
Think about your answer first, then open it.
Q6. How do you stop credential stuffing?
They're testing: security thinking.
Think about your answer first, then open it.
Q7. How would you rate limit by cost rather than by request count?
They're testing: nuance.
Think about your answer first, then open it.
Q8. Where would you put rate limiting in an architecture?
They're testing: layering.
Think about your answer first, then open it.
Q9. How do you handle limits for clients behind one shared IP?
They're testing: real-world awareness.
Think about your answer first, then open it.
Q10. Design a rate limiter as a service used by many teams.
They're testing: scaling the idea (Chapter 32 covers it fully).
Think about your answer first, then open it.