📖 Book · coding challenges · high
🏆 Rate limiting: the token bucket
Burst-friendly limiting in O(1) time and memory — with the lazy-refill trick and the distributed version.
Design a rate limiter: the four classic algorithms and their trade-offs, a complete runnable token-bucket with lazy time-based refill (no timer thread), why it beats fixed windows, and how to make it distributed with Redis.
4 chapters▶ runnable code✦ in-depth animation
▶ See it animated:Rate Limiter — Token Bucket + Hierarchical Limits →
What this book covers
- 01“Limit a client to N requests per second”
- 02Token bucket — run it
- 03Why token bucket beats fixed windows
- 04Scaling it out
Read it in full — runnable C++ + step-through animations
Every chapter of Rate limiting: the token bucket ships complete, editable code you compile and run in the browser, plus the same in-depth animations as the lessons.