Try
↑ ↓ move↵ openesc close

Interview prep / Queues as buffers

Junior · Queues as buffers · System design interview question

Why put a queue between a producer and a consumer instead of calling the consumer directly?

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

A strong answer

A queue decouples the two in time and in speed. The producer hands over the message and moves on. The consumer takes it when it is ready. Bursts that would overwhelm a direct call turn into a short wait.

It also lets the two sides fail and scale on their own. A consumer that is down for a minute does not stop the producer, as long as the queue has room.

The cost is delay, one more component to run, and a decision about what happens when the queue is full. Keep one limit in mind: a queue smooths bursts, and it never creates capacity.

Sources

Learn it by running it

The queues as buffers 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