Reliability & Latency
Token bucket, leaky bucket, and sliding window to control request rates
Protect services and enforce fairness by controlling the rate of requests using algorithms like token bucket, leaky bucket, or sliding window counters.
When you must protect upstream capacity, prevent abuse, or enforce per-user/API quotas at the edge or service level.
Public APIs, multi-tenant platforms, and resource-intensive operations.
# Token bucket sketch
if tokens(user) > 0:
consume()
allow()
else:
reject(429)
Per-token and per-IP API limits
Billions of API requests/dayEdge WAF + rate limits at POPs
20%+ of internet trafficAPI tiering and dynamic quotas
Global real-time APIDistributed or per-instance
Medium - Counters and coordination
Low to Medium - Cache or proxy costs