Architectural Breakdown & AnalysisFAANG Aligned
Rate limiters protect infrastructure using different traffic shaping algorithms.
| Algorithm | Handles Traffic Bursts? | Memory Footprint | Implementation Complexity |
|---|---|---|---|
| Token Bucket | Yes (up to bucket capacity) | Low (Tokens + LastRefillTime) | Simple |
| Leaky Bucket | No (Smooths output rate) | Low (FIFO Queue) | Medium |
| Fixed Window | Yes (Resets per window) | Extremely Low (Counter integer) | Simple |
| Sliding Window Log | Yes | High (Stores timestamps) | Complex |
Algorithm Choice Guidelines
- Use Token Bucket for general API rate limiting where brief user bursts are acceptable.
- Use Leaky Bucket when downstream services require smooth, non-bursty ingress rates.
NOTE — Industry Standard
Token Bucket powers rate limiters in Nginx, AWS API Gateway, and Guava RateLimiter.