SRE & Observability (50 Qs)•Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)
How does Distributed Rate Limiting work with Redis and Token Bucket?
senior LevelMost AskedSecurity & AuthSystem Design
In Simple Words:
- Token Bucket Algorithm: A bucket has a maximum capacity of $B$ tokens and refills at a steady rate of $R$ tokens per second.
- Each request consumes 1 token. If the bucket is empty, requests are rejected (HTTP 429).
- Handled atomically in distributed clusters using an in-memory Redis Lua script or Envoy proxy rate-limit service.