Try
↑ ↓ move↵ openesc close

Interview prep / Load shedding and backpressure

Junior · Load shedding and backpressure · System design interview question

A queue between your web tier and a worker pool keeps filling up during traffic spikes. A teammate suggests raising its limit from 1,000 to 100,000 so nothing is ever dropped. What is wrong with that?

Sketch your own answer first, then compare it with the one below.

A strong answer

A bigger queue does not make the workers faster. It only lets more work wait. Suppose the workers finish 100 jobs a second. A full queue of 1,000 means a wait of 10 seconds. A full queue of 100,000 means a wait of 1,000 seconds, more than 16 minutes. Nobody waits that long, so the work would be finished for callers who have left, or finished so late that it is worthless.

The drop at 1,000 was doing a useful job. It told the sender early that the system was full, while the sender could still react.

The sensible size comes from the delay you can tolerate. If a job is useless after 5 seconds and workers do 100 a second, the queue should hold well under 500 jobs. If a spike is short, a modest buffer absorbs it. If the spike is long, a buffer only postpones the failure, and the answer is to shed, slow the senders or add workers.

Large, always-full buffers have a name in networking, bufferbloat, and the cure there is the same: control how long things wait, not how many.

Sources

Learn it by running it

The load shedding and backpressure lesson explains the mechanism behind this question, and its lab lets you change the parameters and watch the effect.

Your progress is saved in this browser. Sign in to keep it on every device. Privacy · Terms