Try
↑ ↓ move↵ openesc close

Interview prep / Load shedding and backpressure

Senior · Load shedding and backpressure · System design interview question

You are designing a pipeline where a fast producer feeds a slow consumer. Compare dropping, blocking, credits and pull-based flow control.

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

A strong answer

Dropping discards items when the buffer is full. It never slows the producer and keeps latency low, and it loses data. It suits telemetry or video frames and not payments.

Blocking makes the producer wait when the buffer is full. Nothing is lost and the producer slows to the consumer's pace. The risk is that a stall travels upstream and ties up threads, and a cycle of blocked components can deadlock.

Credit-based flow control has the consumer tell the producer how many items it can accept, and the producer sends only that many. The producer never overruns the consumer, and the signal is explicit and cheap to send. It needs a channel for credits, and its latency matters, because a slow credit return leaves the producer idle.

Pull-based flow control has the consumer ask for the next items when it is ready. It gives the consumer full control. Streaming libraries often expose it as a request for a number of items, so it is credits in another form.

Pick by what loss and delay cost for this data. Whichever you choose, the signal has to reach the true source of the work, or the slack just moves somewhere else.

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