3/17
Part 2 of 7 · The token bucketLearn

A token bucket allows a burst, then a steady rate

Anthropic's docs say the API uses the token bucket algorithm: capacity is replenished continuously up to the maximum, instead of reset at fixed intervals. AWS's API Gateway docs name its two settings. The rate is how fast tokens are added, and the burst is the bucket's capacity.

Each customer gets a bucket. A request spends a token, and the bucket refills at a steady rate up to its capacity.

Predict

A customer's bucket holds 5 and refills 10 a minute. They've been quiet for an hour. How many questions can they send at once?

Pick an answer above to see the rest
Predict

The burst leaves the bucket almost empty. Which of the questions at 4, 8 and 10 seconds get through?

Pick one to see what it prints.
Pick an answer above to see the rest