Sliding Window
ELI5 — The Vibe Check
Sliding window rate limiting counts requests in a moving time window. Instead of resetting at fixed intervals (which lets you burst 2x at the boundary), it always looks back exactly N seconds. Smoother rate limiting, no boundary exploits.
Real Talk
The sliding window algorithm tracks request counts in a continuously moving time window rather than fixed intervals. It combines the precision of per-request tracking with the efficiency of fixed windows. A common optimization (sliding window counter) interpolates between the current and previous fixed windows based on the overlap ratio, providing approximate but efficient rate limiting.
When You'll Hear This
"Sliding window prevents the double-burst exploit at fixed window boundaries." / "We use a sliding window counter for rate limiting — it's accurate enough with much less memory than a log."
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.
Token Bucket
A token bucket is a rate limiting algorithm. Imagine a bucket that fills with tokens at a steady rate. Each request costs one token.