Problem Statement
At the code level, which structure is a simple base for a token bucket rate limiter?
Explanation
Tokens represent allowance. You atomically decrement on each request and refill at a steady rate.
Use monotonic clocks and per-key buckets; persist to a store like Redis when distributed.
Code Solution
SolutionRead Only
if(tokens.get(k) > 0){ tokens.decr(k); allow(); } else deny();Practice Sets
This question appears in the following practice sets:
