Labs

Rate limiter playground

Fire bursts at a token bucket, a fixed window and a sliding window, and see which requests get a 429.

Traffic pattern
0.0 s
Token bucketB = 10full: refill waits0 ok · 0 × 429
Fixed windowwindow 0–10 s: 0 / 20 used0 ok · 0 × 429
Sliding window log(0.0, 0.0] s: 0 / 20 in the log0 ok · 0 × 429

admitted · 429 · token

Requests sent40over 60 s
Token bucket13most admitted in any 10 s (L = 20)
Fixed window40most admitted in any 10 s (L = 20)
Sliding window log20most admitted in any 10 s (L = 20)
Token bucket13 ok · 27 × 429
Fixed window40 ok · 0 × 429
Sliding window log20 ok · 20 × 429

admitted · 429 · busiest 10 s · dashed lines: window boundaries · time 0 → 60 s

The fixed window admitted 40 requests in one 10 s span with L = 20: two windows' quotas meet at the boundary (up to 2×).

How it's calculated · assumptions

r = L ÷ W = 2/s · most admitted in any W: sliding log ≤ L = 20, token bucket ≤ B + r·W = 30, fixed window ≤ 2L = 40

The sliding log is exact but stores a timestamp per request; the token bucket allows bursts up to B and averages r, which is why it's the default. Answer the rest with 429 + Retry-After.

Dots: requests (green admitted, red 429) · amber: tokens · in the windows, the fill is the count against L · quiet stretches play 8× faster (⏩).

Simulated in your browser: one client, one limiter instance (with many gateway replicas, keep counters in Redis). W = 10 s, the bucket starts full, the sliding log keeps admitted timestamps only; streams are seeded, so they repeat. Rules from the rate limiting concept; 429 is defined in RFC 6585.