Implement a Rate Limiter Class

Medium · Low-Level Design · about 40 minutes

Asked at Cloudflare, OpenAI, Stripe, Twilio, Uber, Datadog, Perplexity, Arista Networks, Okta, Vercel, Akamai.

Implement an in-process rate limiter: allow(clientId) returns whether a request is permitted. Support token bucket and sliding window algorithms behind one interface, configurable per client, and safe under concurrency.

Related guides