Token Bucket
ELI5 — The Vibe Check
A token bucket is a rate limiting algorithm. Imagine a bucket that fills with tokens at a steady rate. Each request costs one token. If the bucket is empty, you're rate limited. If it's full, you can burst a bunch of requests at once. It balances steady throughput with burst tolerance.
Real Talk
The token bucket algorithm controls request rate by maintaining a bucket that refills at a fixed rate (tokens per second). Each request consumes a token. If the bucket is empty, the request is rejected or queued. The bucket has a maximum capacity allowing burst traffic up to that limit. It provides smoother rate limiting than fixed window approaches.
When You'll Hear This
"Our rate limiter uses a token bucket allowing 100 requests/minute with bursts up to 20." / "Token bucket is more forgiving than fixed window because it allows short traffic bursts."
Related Terms
Fixed Window
Fixed window rate limiting counts requests in fixed time blocks (e.g., per minute). Simple: reset the counter every 60 seconds. The catch?
Leaky Bucket
A leaky bucket processes requests at a fixed rate, like water dripping from a bucket. No matter how fast requests pour in, they come out at a steady drip.
Rate Limiting
Rate limiting is like a bouncer who says 'you can come in 100 times per hour, then you wait.
Sliding Window
Sliding window rate limiting counts requests in a moving time window.