Build fluency in the vocabulary of queuing requests and draining them at a strictly steady rate to smooth out bursts.
0 / 5 completed
1 / 5
At standup, a dev mentions queuing incoming requests into a bucket of limited capacity and draining, or processing, them out at a strictly steady rate, regardless of how bursty the arrivals were, discarding new requests only once the bucket is completely full. What is this algorithm called?
Leaky bucket algorithm is exactly this: the leaky bucket algorithm queues incoming requests into a bucket of limited capacity and drains, or processes, them out at a strictly steady rate regardless of how bursty their arrival was, discarding any new request only once the bucket is already completely full. A hash collision is an unrelated hash-table concept about two keys sharing a bucket. This queue-then-drain-at-a-fixed-rate approach is exactly why the leaky bucket algorithm smooths bursty traffic into a perfectly steady output stream.
2 / 5
During a design review, the team uses the leaky bucket algorithm to protect a downstream service that can only handle a strictly steady request rate, specifically because draining queued requests at a fixed rate smooths out bursty arrivals into a perfectly steady output stream, unlike a scheme that lets bursts pass straight through. Which capability does this provide?
Leaky bucket algorithm here provides Smoothing bursty arrivals into a perfectly steady output rate, since requests sit in the bucket's queue and are drained one at a time at a strictly fixed rate, so the downstream service only ever sees a perfectly steady stream regardless of how clustered the original arrivals were. A scheme that passes every incoming burst straight through to the downstream service unsmoothed can overwhelm that service the instant traffic clusters. This burst-smoothing behavior is exactly why the leaky bucket algorithm is favored when a downstream service specifically needs a steady, predictable request rate.
3 / 5
In a code review, a dev notices a feature protecting a downstream service that can only handle a strictly steady request rate passes every incoming burst straight through unsmoothed, instead of queuing requests and draining them out at a fixed rate. What does this represent?
This is a missed leaky-bucket opportunity, since using the leaky bucket algorithm's queue-and-drain-at-a-fixed-rate approach would smooth bursty arrivals into the steady stream the downstream service actually needs. A cache eviction policy is an unrelated concept about discarded cache entries. This pass-bursts-through pattern is exactly the kind of risk a reviewer flags once the downstream service is confirmed to require a strictly steady request rate.
4 / 5
An incident report shows a downstream service that could only handle a strictly steady request rate was repeatedly overwhelmed during traffic spikes, because incoming bursts were passed straight through unsmoothed instead of being queued and drained at a fixed rate. What practice would prevent this?
Adding a leaky bucket in front of the downstream service removes the risk of overwhelming the downstream service during a traffic spike. Continuing to pass every incoming burst straight through to the downstream service unsmoothed regardless of how bursty the actual incoming traffic is is exactly what caused the issue described in this incident. This leaky-bucket approach is the standard fix once a downstream service is confirmed to require a strictly steady request rate regardless of arrival burstiness.
5 / 5
During a PR review, a teammate asks why the team reaches for the leaky bucket algorithm instead of the token bucket algorithm, given that the token bucket algorithm is also a classic rate-limiting scheme built around a bucket metaphor. What is the reasoning?
The leaky bucket algorithm drains requests at a strictly steady rate, producing perfectly smoothed output ideal for protecting a downstream service, while the token bucket algorithm allows a client to briefly burst above the steady rate using stockpiled tokens, which suits limiting client request rates but doesn't guarantee that same perfectly steady output. This is exactly why the leaky bucket algorithm is favored for smoothing traffic into a downstream service, while the token bucket algorithm is favored for tolerating legitimate client bursts.