Try
↑ ↓ move↵ openesc close

Interview prep / Queues as buffers

Junior · Queues as buffers · System design interview question

A dashboard shows 10,000 messages in a queue. Should you worry?

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

A strong answer

Not from that number alone. Depth only becomes meaningful next to the drain rate. If the consumers finish 5,000 a second, 10,000 messages is two seconds of work. If they finish 10 a second, it is more than 16 minutes.

Little's law gives the second view. Divide depth by the arrival rate and you get the average wait in the queue. At 500 arrivals a second, 10,000 waiting means about 20 seconds.

Then check the direction. A depth of 10,000 that was 12,000 an hour ago is draining. The same depth that was 2,000 an hour ago is growing, and growth means arrivals exceed capacity. So I would look at three things together: depth, its trend, and the age of the oldest message, which is what a user actually experiences. Whether 10,000 is fine depends on how long a message can wait before it stops being useful.

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