FFORGE//RS
← Roadmap

distributed systems / LEVEL 4

The limiter that minted free traffic

EST.45 MIN
01

THEORY / RETRIEVAL

What to restore

  • Model fractional token refill without losing precision
  • Cap accumulated credit and handle non-monotonic timestamps
  • Separate local admission control from a global product quota

A token bucket has two independent knobs

Capacity defines the allowed burst; refill rate defines sustained throughput. Conflating them either rejects healthy bursts or allows an overload to persist. Admission should happen before scarce work and should return an explicit retry or shedding signal.

Time and scope are correctness choices

A process-local limiter is fast but cannot enforce one global quota across replicas. A distributed limiter needs atomic shared state, partitioning and a failure policy. Refill calculations should use monotonic elapsed time and must not mint credit when timestamps move backward.

CHECKPOINT

Eight API replicas must enforce one strict tenant quota. Which design property is missing from eight independent in-memory token buckets?

ISOLATED RUST 1.96
src/lib.rsEDIT

02 / DEBUGGING

Find and fix the defect

Repair the token bucket. It stores milli-tokens so sub-second refill is exact, must never exceed capacity, and must ignore timestamps older than the last observed instant.

Initializing editor…
CLOUD SANDBOXnetwork off · 256 MB · 12 s
1 / 64 KB
OUTPUT
Runner is waiting for a submission.