Skip to content
BENIBIX Learn

Message Queue

Development🏗️ ArchitectureEvents and Messages

Also known as Queue, Job Queue, Task Queue, Message Broker

A line where messages wait for a free worker.

Think of it like

Think of it like a line at a bakery. Each order waits its turn for a free baker.

Example

Jack's site lets people upload videos. Each upload adds a message to a queue. Four workers take messages out and convert the videos, while the site stays fast.

Why it matters

Slow jobs move out of the web request, so users are not kept waiting. Spikes of traffic just make the line longer.

Definition

A message queue holds messages until a worker is ready for them. They come from one part of a system and go to another. The sender, or producer, drops a message in and moves on. A worker, or consumer, takes messages out one at a time and does the work. Each message is usually handled by just one worker. If workers are busy or down, messages wait safely in the queue.

Common mistake

Assuming each message is handled exactly once. Most queues may deliver one twice, so the work must be safe to repeat.

Key takeaways

  1. 1
    Producer drops it in. And moves on.
  2. 2
    One worker takes it. When it is free.
  3. 3
    Waits safely. Through spikes and outages.

Compare