Skip to main content

Design a distributed API Rate Limiter

Enforce per-user and per-IP limits across 50 stateless API servers with <5ms overhead and clear 429 headers.

Official Reference

Model Answer & Explanation

Place gateway middleware calling a sharded Redis cluster running atomic Lua scripts (token bucket or sliding-window counter), returning X-RateLimit-Remaining and Retry-After on 429. For ultra-high QPS, synchronize local in-memory counters to Redis asynchronously at small intervals, and fail open on Redis outage with alerting.

Follow-up Interview Question · How do you avoid a hot Redis shard when one tenant sends 50,000 requests/second?

Module Context & References

System Design · Widely asked design scenarios The 80/20 classic architecture prompts: requirements, data model, bottlenecks & tradeoffs
Personal Notes · Markdown

Technologies & Interview Topics Covered

Switch between short-term interview tracks and long-term 80/20 engineering depth to practice JavaScript internals, React rendering and hooks, timed frontend machine coding UI challenges, MeetaPro FG300, Blind 75 & NeetCode 150 DSA patterns, Python & FastAPI APIs, PostgreSQL query optimization & MVCC, Redis caching, Applied AI RAG pipelines & evaluations, and distributed system design.