LOWPOLYCOMPSCI

INTERACTIVE COMPANION / 01

CAN YOUR API HANDLE A BURST?

An app asks a server for data. A rate limiter decides which requests may pass. Try sending eight at once.

TOKEN BUCKET0.0s · PAUSED
One token lets one request through.

Your app

Asks for data

Permission tokens

4 available

1 token every 0.5s, up to 4

READY

Server

Admitted requests

0

Refused requests 0

Not queued. The app must retry later.

The bucket starts full. Send a burst to see the limit.

The request trail

■ Passed · × Refused · most recent 32 requests

What just happened?

    PREDICT. TEST. UNDERSTAND.

    Same bucket. A second burst.

    A full bucket holds 4 tokens and refills 2 per second. Send 8 requests, wait exactly 1 second, then send 3 more. How many of the second burst pass?

    Choose a prediction. Then watch both bursts unfold.

    Two knobs. Two different effects.

    Capacity determines how many saved tokens can absorb a sudden burst. Refill rate determines how fast permission returns. Idle time never fills the bucket beyond its capacity.

    What would happen if every refused request retried immediately? Try sustained traffic with a slow refill.