What Are Message Queues?

system-design

Nov 1, 2025 at 14:35 pm

source

Message queues store messages — packets of data that one application (the producer) creates for another application (the consumer) to process later. These messages are held in the queue in the order they were sent, until the consuming application is ready to handle them.

blog image

Consider a distributed application where users can upload videos (like Youtube). The challenge for us is to upload the video using UploadVideoService, track this event, and push it one of analytics services - UserAnalyticsService.

But here’s the catch: there can be multiple services handling uploads and multiple services handling analytics.

So, how do they communicate with each other reliably and efficiently?

That’s where message queues come in.

A message queue acts as a buffer or communication channel between services. It stores log entries or event data that can later be consumed by other services.

In our example:

  • UploadVideoService (the producer) writes metadata about a newVideoUpload event to the message queue.
  • UserAnalyticsService (the consumer) then reads this metadata from the queue and processes it asynchronously.

Some popular message queue implementations include RabbitMQ, Apache Kafka, AWS SQS (Simple Queue Service), and Google Cloud Pub/Sub.

Each of these provides a slightly different way to handle message delivery, persistence, and scaling — but they all serve the same core purpose: enabling reliable, asynchronous communication between distributed systems.