← All parts

Capacity Planning

Design a Distributed Rate Limiter · Part 5
Problem context

Design a service that decides, for each incoming API request, whether to allow it or reject it because the caller has exceeded a configured rate. The limiter sits in front of an API gateway or an internal RPC fabric, must answer in single-digit milliseconds, and must keep working when individual nodes — or an entire datacenter — fail.

The naive single-process counter falls over once two app servers sit behind a load balancer. The rest of the design is about what to do next. Adjacent problems — quotas, billing, and DDoS defense — are separate systems and out of scope here.

Scale and usage:

State per key is tiny for most algorithms. Ten million active keys with a sliding window counter at two integers each is 10M × 24 bytes ≈ 240 MB — a single node holds it many times over. The sliding window log is the outlier: at 100 requests per minute it stores up to 100 timestamps per key, 10M × 5 KB ≈ 50 GB (up to 100 GB with overhead), which is the dominant storage cost on that path, especially once replicated.

What a strong answer sounds like

State the decision, connect it to a requirement, and name the tradeoff. Ask the interviewer for any product facts you need (users, usage, scale, targets) — they will answer. Keep the design focused on the workload.

Ready for the capacity planning interview?

The AI interviewer asks about this part of Design a Distributed Rate Limiter. The interviewer guides you through topics one by one.