Beginner · INTERACTIVE LESSON
Token-bucket rate limiting
Watch requests consume tokens, compare shared and per-client limits, and see how refill controls admission.
The interactive player is loading. If it does not appear, you can still read the explanation below.
THE IDEA BEHIND THE STEPS
How it works
A token bucket starts with a fixed capacity of tokens. Each admitted request consumes one token. Tokens refill with elapsed time at a configured rate, up to capacity. A request with no token is rejected with 429 Too Many Requests and does not reach the service.
Choose one request at a time or concurrent bursts. Request count is the total across clients, assigned in round-robin client order. Arrival interval is between requests or bursts, not per client. Burst size is the total number submitted at the same timestamp; several can come from one client. The table shows atomic admission decisions in request-ID order. No tokens refill between checks at the same timestamp.
A shared bucket constrains aggregate admission but does not guarantee fair sharing. Per-client buckets isolate token usage; three clients with separate buckets have three times the aggregate budget of one shared bucket with the same settings. In real systems, per-client limits may need an additional global limit.
Capacity permits short bursts; refill rate governs sustained admission. Idle time restores tokens only up to capacity, and completing a request does not return tokens. Rate limiting does not itself bound in-flight requests or prove a service can handle admitted traffic.
This deterministic teaching model checks and decrements atomically. It does not model distributed coordination, retries, queues or service capacity. Message animations take no simulated time; the clock advances between arrival groups. It is not a vendor-specific limiter emulator.