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

  1. Enter capacity, tokens, rate, cost. Use the exact text syntax, units and index conventions explained below.
  2. Run the tool. If input validation fails, correct the supplied fields before interpreting any result.
  3. 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 fieldMeaning and representationAccepted input
capacitycapacity.Finite number
tokenstokens.Finite number
raterate.Finite number
costcost.Finite number
Output fieldInterpretation
resultObject containing the named outputs below.
result.possibleFlag for possible under the exact condition described above.
result.delayThe delay value under the stated formula or text convention.
json
{
  "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

  1. Tool behavior and example: Token Bucket Next Admission Delay — tool.io

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.

Don't forget to set a bookmark for tool.io!
Privacy | Imprint | Cookies