Skip to main content

Rate limiting algorithms: token bucket vs sliding window

Compare token bucket, leaky bucket, fixed window and sliding window counter. Where should enforcement live?

Official Reference

Model Answer & Explanation

Token bucket allows controlled bursts up to capacity while enforcing a steady refill rate (great for APIs). Fixed window is simple in Redis (INCR + EXPIRE) but allows 2x bursts across window edges. Sliding window counter smooths edge spikes with O(1) memory. Enforce coarse IP limits at the edge/API gateway and per-tenant/token-budget limits in Redis at the app layer.

Follow-up Interview Question · Should rate limiting fail open or fail closed if Redis becomes unreachable?

Module Context & References

System Design · Popular interview theory The 20% of distributed systems building blocks behind 80% of architecture rounds
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.