freecoding.school100% FREE · NO SIGNUP
Gateway RidgeISSUE #2 of 35

rate limiting · token bucket · sliding window

Gateway GusVSTimeout Titan
Gateway Gus saysCommon rate-limit algorithms: token bucket, leaky bucket, fixed and sliding windows.

Token bucket refills tokens at a steady rate and allows bursts up to the bucket size — the popular default. Leaky bucket drains at a constant rate (smooths bursts). Fixed window counts per clock interval (simple but spiky at boundaries); sliding window smooths that boundary problem. Each trades simplicity against burst behavior.

Power-ups you unlock

Timeout Titan attacks — common mistakes

Boss battleExplain why token bucket is favored for APIs that should tolerate short bursts.

Example code

<!doctype html><html><head><meta charset="utf-8"></head>
<body style="background:#06040d;color:#e6e0ff;font-family:monospace;padding:20px"><pre>token bucket: +1 token / 600ms, cap 100
burst of 100 OK, then throttled to refill rate</pre></body></html>
▶ Open the interactive comic issue
‹ Rate Limiting · Protecting The ApiRetry-After · Backoff · Idempotency ›