Question library
Questions from real interviews. Drill any of them by voice in a couple of minutes, with an interviewer, a score and feedback.
Design 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-levelDesign a distributed rate limiter for a public API: limits are set per client key, and requests are handled by dozens of gateway instances.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.SeniorWrite 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.Senior