Ctrl K
Backend · Senior · System design

Design a distributed rate limiter for a public API: limits are set per client key, and requests are handled by dozens of gateway instances.

~10 min by voice

How to approach it

This checks whether the candidate can design shared state for dozens of instances: choose a rate-limiting algorithm, ensure atomicity without races, and deliberately balance accuracy, latency and fault tolerance.

Have you seen this question in a real interview?
Answers0
Avg. score—
Strong—
Practiced0
Topics
Similar questionsWrite a thread-safe RateLimiter class: the constructor takes how many requests per second are allowed, and the tryAcquire method, without waiting, returns true if the request can be let through and false if the limit is exhausted. It will be called concurrently from many threads. SeniorWrite a rate limiter for an API using the token bucket algorithm: an allow function takes a client identifier and returns whether its request can go through. Each client has a bucket capacity and a token refill rate per second, and the limiter itself is called from many threads at once. SeniorDesign a rate limiter for a public API: for example, no more than 100 requests per minute per API key. The service runs on several instances. Mid-levelThe main table in your database has grown to several terabytes, and a single instance can no longer keep up with the writes. How would you design the move to sharding? SeniorYour service makes synchronous calls to an external service that sometimes responds very slowly or with errors. How do you keep that from taking your service down? Mid-level

Answer by voice

The interviewer will ask this question and listen. Think out loud and ask for a hint if you need one. When you're done, pause or tap “That's my answer”. In about a minute, your score and the points you covered show up here.

Sign in to answer

Best with headphones · ~10 min