Backstage Token Bucket
A huge crowd rushed the backstage door! Build a fair gate that uses one ticket token for each entry and refills safely on the beat.
π§ Before we start
At the Volcano, you checked fresh loads before routing each job. Today, a rate limiter protects one busy door. A token bucket allows quick bursts but makes extra work wait until new tokens arrive.
Arrange the backstage rules
Tap five visual instruction blocks in the order the token gate should follow.
Follow the show timeline
Read each event. On a beat, refill one token. When a fan arrives, admit only if a token is ready; otherwise make them wait.
Smooth a sudden crowd burst
Five fans arrive at once, but the bucket holds only three tokens. Tap each fan and decide who enters now. Then use drum beats to release the waiting line.
Debug the overflowing bucket
The buggy refill keeps adding tokens beyond the bucket's capacity. Choose the rule that protects the gate.
π What you learned
- A rate limiter protects a busy service from too much work at once.
- A token bucket refills over time and spends one token for each allowed job.
- Ready tokens allow a small burst to pass immediately.
- When tokens run out, extra work waits for later refill beats.
- A capacity rule stops saved tokens growing without a limit.