System Design Visualized
Lesson 1.10

Message queue

Play this lessonThis lesson comes with an interactive animation you can break, a live-code challenge and a chapter quiz.

A message queue is a durable, in-memory buffer that lets parts of a system talk asynchronously: one side drops work into it, and the other side picks the work up whenever it's ready.

  • Producers (publishers) post messages to the queue.
  • Consumers (subscribers) connect to the queue and do the work in each message.

The big win is decoupling: the producer can publish even when no consumer is available, and a consumer can read messages even when the producer is offline. Each side can be scaled independently.

Example: photo processing (crop, sharpen, blur…) is slow. Web servers just publish "process photo #42" jobs. Photo-processing workers pick them up. When the queue grows, add workers; when it's empty, remove some.

Key takeaways

  • Producers publish, consumers process, at their own pace.
  • Queues decouple components and absorb traffic spikes.

Remember it, then prove it

Create a free account to save your progress, get spaced-repetition reviews of what you miss, and design real systems in the interview simulator.

Start free