HomeAI & Machine LearningModelling API Rate Limiting: Token Buckets, Sliding Windows, and Request Queues

🚦 Modelling API Rate Limiting

How the token bucket, fixed window, and sliding window algorithms decide which API requests get through and which get throttled, and why the choice of algorithm changes the shape of traffic a backend actually experiences.

AI & Machine Learning3DAdvanced60 FPS
api-rate-limiting-token-bucket-sliding-window-simulation-lab ↗ Open standalone

Requests stream toward a gate where a token bucket, fixed window, or sliding window algorithm decides in real time whether to let each one through or throttle it — watch the live capacity gauge and strip chart change shape as you switch algorithms.

🔬 What It Demonstrates

Each algorithm is run against the exact same incoming traffic. The token bucket refills and drains smoothly; the fixed window snaps to zero at each boundary; the sliding window log decays continuously — the differences you'd normally only see in a graph become a physical, moving gauge.

🎮 How to Use

Pick an algorithm, set the incoming request rate and the limit/capacity, then tune the refill rate or window length. Fire a burst to see how each strategy absorbs a traffic spike, and toggle queuing to compare dropped versus retried requests.

💡 Did You Know?

Fixed window counters can let up to 2x their stated limit through in a short span if a burst straddles a window boundary — half the requests land in the tail of one window, half in the head of the next.

⚙ Under the hood

How the token bucket, fixed window, and sliding window algorithms decide which API requests get through and which get throttled, and why the choice of algorithm changes the shape of traffic a backend actually experiences.

machine learningalgorithmsrate limitingtoken bucketssliding windowsapi designThree.js

3D · Three.js / WebGL renderer · 60 FPS target · runs fully client-side, no install

What did you find?

Add reproduction steps (optional)