Token Bucket Next Admission Delay
Compute deterministic next token-bucket admission delay with null for impossible requests; assumes constant refill and no intervening consumption.
Description
Compute deterministic next token-bucket admission delay with null for impossible requests; assumes constant refill and no intervening consumption.
A token bucket can admit a cost only if it fits capacity and sufficient tokens can become available.
When to use this tool
Compute deterministic next token-bucket admission delay with null for impossible requests; assumes constant refill and no intervening consumption.
- Prepare the supplied capacity, tokens, rate, cost fields for this operation.
- Compare the complete example with the representation used by your own input before carrying the result into another step.
How to use the tool and how it works
- Enter capacity, tokens, rate, cost. Use the exact text syntax, units and index conventions explained below.
- Run the tool. If input validation fails, correct the supplied fields before interpreting any result.
- Read result.possible, result.delay. Interpret false, null and empty lists using the distinctions below; they can be valid outputs.
Require nonnegative capacity, tokens within capacity, rate and cost. If cost exceeds capacity, or exceeds tokens with zero refill rate, return possible false and delay null. Otherwise return max(0,cost minus tokens)/rate, with immediate admission at zero delay.1
| Input field | Meaning and representation | Accepted input |
|---|---|---|
| capacity | capacity. | Finite number |
| tokens | tokens. | Finite number |
| rate | rate. | Finite number |
| cost | cost. | Finite number |
| Output field | Interpretation |
|---|---|
| result | Object containing the named outputs below. |
| result.possible | Flag for possible under the exact condition described above. |
| result.delay | The delay value under the stated formula or text convention. |
{
"input": {
"capacity": 10,
"tokens": 2,
"rate": 2,
"cost": 5
},
"output": {
"result": {
"possible": true,
"delay": 1.5
}
}
} Limitations and assumptions
- Time units follow the supplied refill rate. The tool does not update bucket state, schedule a request or model concurrent consumers.
- All declared input fields are required and unexpected top-level fields are rejected. Numbers must be finite; lists are limited to 128 entries and ordinary text fields to 8,192 UTF-16 code units, with tighter limits where stated.
- JSON text inputs must parse within bounded nesting and size limits. Numeric outputs outside the safe finite range are rejected; large exact integer results use decimal strings. Indexes and half-open spans are zero-based unless a rank is explicitly described as one-based.
Alternative or Complementary methods
Check the arithmetic against the actual scheduling or storage policy. Add variable costs, arrivals, concurrent state and overhead in a model that explicitly represents them when they affect the decision.
References
Similar or alternative tools
- Token Bucket Single Event Update
Apply one deterministic token-bucket event with bounded refill and all-or-nothing consumption; no real-time state, burst guarantee or distributed synchronization.
- Per Item Prefix Capacity Admission
Admit only the longest affordable ordered prefix of explicit per-item costs; after the first failure later cheaper items are not skipped into admission.