Explain like I'm five · SRE

What is a Message Queue?

A message queue, told as a story about a snack counter that stacks order slips in a basket instead of handing them straight over.

SNACK COUNTERtoo many at once!orders pile up all at once and the clerk can't keep up

Orders pile up all at once and the clerk can't keep up.Too many at once!

still can't place my order?I can't even get to itif the sender must wait while the receiver is busy, both slow down

Why: if the sender must wait while the receiver is busy, both slow down.The sender and receiver get tied to each other's pace.

ORDER BASKETput orders in a basket, and sender and receiver each move at their own pace

Put orders in a basket, and sender and receiver each move at their own pace.The sender moves to the next guest; the receiver works at its own speed.

Neither side has to waitthis is asynchronous processing
They stack in orderin the same order they came in
A backup doesn't break itthe basket just gets longer
More workers empty it fasterby adding more handlers
order placerQUEUED ORDERSone-at-a-time pickera basket sits between the sender and the receiver

Order placer → queued orders → one-at-a-time picker.A basket sits between the sender and the receiver.

the basket got too longthe old orders are way too latetoo long delays old orders, and dropping one loses it forever

Too long delays old orders, and dropping one loses it forever.Length is handled with backpressure; drops with a dead-letter queue.

In one breath

A message queue: instead of handing orders straight over, they're stacked in a basket so the sender and receiver can each move at their own pace.

The sender side is called the producer, the receiver the consumer. Multiple consumers can watch the same basket (pub/sub), and items usually come out in the order they went in. Adding more consumers empties the basket faster.

When grown-ups say it

Message Queue
The basket that holds the order slips. It keeps the sender and receiver from having to wait on each other.
Asynchronous Processing
Sending something without waiting right away for a reply. Possible because the basket sits in between.
Producer / Consumer
The one who puts orders in, and the one who takes them out. They don't need to know each other — just share the same basket.
Queue Length
How many order slips are piled in the basket. Too long, and old orders get handled too late.
Pub/Sub
Several people watching the same basket together. Also called publish-subscribe.
Ordering Guarantee
The promise that things come out in the order they went in. Not every queue promises this.
Backpressure
Holding the entrance shut for a moment before the basket gets too long. → briefly closing the entrance
Dead-letter Queue
A separate box for order slips that keep failing to be handled. → the basket nobody came to claim
Next story
The Basket Nobody Came to Claim →
Want another term as a picture book? Request →