Explain token bucket rate limiting.
IntermediateConceptRelease Engineering & Reliability Patterns
Answer
A bucket holds up to B tokens and refills at R tokens per second. Each request consumes a token; if the bucket is empty, the request is rejected (429) or delayed. It allows bursts up to B while enforcing an average rate R. NGINX's limit_req uses the closely related leaky bucket:
limit_req_zone $binary_remote_addr zone=api:10m rate=10r/s;
location /api/ {
limit_req zone=api burst=20 nodelay;
limit_req_status 429;
}
More on Release Engineering & Reliability Patterns
Why are releases the biggest source of incidents, and what does SRE do about it?BeginnerWhat is a canary release?BeginnerWhat is progressive delivery?IntermediateShow an Argo Rollouts canary with a Prometheus analysis.AdvancedBlue-green vs canary: when do you choose each?IntermediateWhat are feature flags and how do they improve reliability?Beginner