Design a distributed rate limiter
GoogleSoftware Engineer · OnsiteLast updated
This question evaluates skills in distributed systems design, concurrency control, rate-limiting algorithms (token bucket and sliding window), distributed coordination and consistency, API design, and operational monitoring for scalability and fault tolerance.
Design a rate limiter to ensure API calls do not exceed a given QPS with optional burst allowance. Compare and implement two approaches (e.g., token bucket and sliding window), specifying data structures, time/space complexity, and correctness under concurrent access. Extend your design to a distributed setting across multiple application instances: discuss coordination (centralized store like Redis vs. sharded counters), clock skew tolerance, atomicity, idempotency, failure modes (node loss, partial updates), and strategies to maintain consistency and fairness. Provide APIs, example configurations, and monitoring/alerting for saturation.
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.