Explain burst capacity by reconstructing the rate-limit state at each arrival. A refill rate and a bucket capacity describe different controls: one governs how capacity returns, while the other limits how much can accumulate. Neither number alone establishes whether a particular request fits now.
Use a token-bucket arrival ledger with the prior balance, elapsed time, refill, saturation, request cost and resulting decision. Keep it separate from a fixed total allowance, a rolling arrival count or a promise about every implementation's enforcement accuracy.
Establish the documented policy first
Record the resource scope, capacity, replenishment rule, initial balance, request cost and rejection behavior. Determine whether replenishment is continuous or occurs in discrete periods. Also establish whether a rejected request consumes capacity under the actual contract.
AWS's API Gateway throttling documentation describes token-bucket throttling, with rate and burst settings. It explicitly says throttles and quotas are applied on a best-effort basis and should be considered targets rather than guaranteed ceilings. Do not turn its algorithm description into a universal hard-cap guarantee.
The precise teaching model below is fictional. Its continuous refill, costs and rejection rule are declared assumptions, not assertions about every API Gateway request or another provider's implementation.
Freeze the complete bucket model
Assume a bucket with capacity five tokens, initial balance five and continuous refill of two tokens per second. Each arrival has a specified token cost. Admission requires the whole cost to fit; a rejected request consumes no tokens. There are no other arrivals.
For each event, first add the elapsed refill to the previous balance and cap the result at five. Then compare the request cost with that available balance. Subtract the cost only if admitted.
The cap matters. After a long idle period, the bucket does not contain an unlimited reserve of historical refill. Time beyond the point at which it became full does not create additional tokens in this model.
Populate the arrival ledger
| Time | Balance After Refill | Request Cost | Decision | Balance After Decision |
|---|---|---|---|---|
| 0 seconds | 5 initial tokens | 4 | Admit | 1 |
| 1 second | 1 + 2 = 3 | 4 | Reject | 3 |
| 1.5 seconds | 3 + 1 = 4 | 4 | Admit | 0 |
| 5 seconds | Minimum of 5 and 0 + 7: 5 | 5 | Admit | 0 |
Between one and one-and-a-half seconds, half a second adds one token. Between one-and-a-half and five seconds, three-and-a-half seconds would add seven, but the bucket retains only five because of its capacity.
A summary saying “two tokens per second means the four-token request can run only every two seconds” misses the initial burst balance. A summary saying “five tokens means five requests per day” substitutes both a different unit and a different replenishment period.
Derive the next eligible instant conditionally
At one second, three tokens are available and the four-token request needs one more. At two tokens per second, the deficit takes half a second to refill. The next eligible instant is therefore one-and-a-half seconds under the declared model.
A request costing more than the bucket capacity never fits this fictional model, regardless of idle time. For example, waiting cannot make a six-token request fit a five-token bucket. That is different from a temporarily depleted balance.
That conclusion depends on no intervening consumption and an unchanged policy. Another admitted request could move the instant later. A policy change or unavailable state observation can also invalidate the calculation.
Do not publish the computed instant as a universal retry instruction. A real API can provide its own response fields, retry rules, queues or other constraints. Verify those before recommending an actual request sequence.
Distinguish the bucket from a rolling count
A rolling-window rule usually needs an arrival history and a lookback boundary. This bucket calculation needs the last state, elapsed time and refill rule. They can produce different decisions for the same broad headline rate.
Similarly, the reservation ledger describes committed and reserved stock. A token bucket's capacity returns through its declared replenishment rule; it is not necessarily restored by a task finishing or a reservation being released.
Keep those models separate in the explanation. A product page may use quota and rate limit loosely, but the source-based answer should identify which actual mechanism governs the request being evaluated.
Verify scope and weighted costs
A real bucket can apply to an account, user, route or another defined boundary. Do not assign its full balance independently to several callers unless the actual contract gives them separate buckets. Shared consumption changes the state another caller encounters.
Also confirm whether every request costs one token. The fictional example uses costs of four and five to make admission visible; those are not claims about any real endpoint. If actual costs differ by operation, retain the mapping with the ledger.
Use the prerequisite matrix for other applicable limits and permissions. Enough bucket capacity does not establish that the requested operation is supported or authorized.
Test saturation and rejection deliberately
A meaningful local fixture includes an initially full bucket, an insufficient arrival, an exact-fit arrival and an idle period long enough to saturate it. Verify the declared rejected-request treatment instead of assuming the rejection behaves like an admitted request.
Preserve the event order and exact time resolution. Two simultaneous arrivals require an actual implementation's shared-state rule; a spreadsheet cannot establish atomic admission. Do not claim concurrency safety from this sequential teaching ledger.
The number check should reproduce every refill and subtraction. Include a negative calculation that carries seven tokens past a five-token cap so the review can detect a missing saturation step.
Preserve evidence when the visible balance is incomplete
A displayed rate setting is not a current balance. A request log without other callers may be incomplete. Record which state was observed, which was inferred and which arrivals are known to be missing before judging a particular response.
The source worksheet should retain the actual provider's rate, burst, scope, refill and response semantics. If that evidence cannot establish the request's available balance, mark its specific admission outcome unresolved.
Release a bounded admission explanation
The completed record should name the policy revision, starting state, arrivals, refill convention, costs and decisions. State the no-intervening-consumption assumption beside any projected next instant.
A useful answer explains why a request fits or does not fit under the supported model. It does not confuse burst capacity with an unlimited bank, a lifetime quota or a guarantee that every real request follows the idealized teaching sequence.
