What Is a Message Queue and Why Do Systems Use One?

What a message queue is, why systems use one for decoupling and async processing, and how Kafka, RabbitMQ, Amazon SQS, and Redis Streams actually differ.

Diagram showing multiple apps producing and consuming data through a central Kafka cluster, with stream processors and databases connected to it
Architecture diagram from Apache Kafka's own documentation. Image: Apache Kafka.

A message queue is a piece of infrastructure that sits between two parts of a system and holds messages — small packets of data — until the receiving side is ready to process them. Instead of one service calling another directly and waiting for a reply, the sending service (the producer) drops a message into the queue and moves on; a separate service (the consumer) picks the message up and processes it whenever it has capacity. That one change — adding a buffer and a broker in the middle — is what lets large systems absorb traffic spikes, survive a consumer going down, and scale producers and consumers independently of each other.

Key facts
  • A message queue decouples producers from consumers: the sender doesn't wait for the receiver to be available.
  • Apache Kafka guarantees that a consumer reads a given partition's events "in exactly the same order as they were written," but it does not order events across different partitions of a topic.
  • RabbitMQ delivers "at least once" when consumer acknowledgements are used, and only "at most once" without them, per RabbitMQ's own reliability guide.
  • Amazon SQS standard queues provide at-least-once delivery; SQS FIFO queues provide exactly-once processing and strict ordering within a message group, per AWS's own documentation.
  • Redis Streams support consumer groups and at-least-once delivery via a pending-entries list, acknowledged with XACK.

What is a message queue?

In system design, a message queue is a communication pattern where one service (the producer) sends a message to an intermediary (the broker), which stores it until another service (the consumer) retrieves and processes it. The producer and consumer never talk to each other directly — they only talk to the queue. That indirection is the entire point: the producer can keep producing even if the consumer is slow, offline, or scaled down to zero, because the broker is holding the messages in the meantime.

This is different from a synchronous request, like a typical REST API call, where the caller blocks until it gets a response. It's also different from a webhook, where one system pushes an HTTP request directly to another system's endpoint the moment an event happens — there's no broker holding messages in between, so if the receiving endpoint is down, the event can be lost unless the sender has its own retry logic. A message queue, by contrast, is built around durable storage and retry as first-class features of the middle tier itself.

Why systems use a message queue

The pattern solves a handful of recurring problems in distributed systems:

  • Decoupling. Producers and consumers don't need to know about each other's existence, location, or implementation language. A service only needs to know how to publish to a queue or topic; it doesn't need a direct network path to every downstream consumer.
  • Buffering traffic spikes. If 50,000 orders arrive in one minute but your inventory service can only safely process 5,000 a minute, a queue absorbs the burst and lets the consumer drain it at a sustainable rate instead of falling over.
  • Asynchronous processing. Slow work — sending an email, generating a report, re-encoding a video — can be handed off to a queue so the user-facing request returns immediately instead of blocking on that work.
  • Independent scaling. You can add more consumer instances to work through a backlog faster without touching the producer side at all, and vice versa.
  • Retries and dead-letter handling. If a consumer fails to process a message, the broker can make it visible again for another attempt, and after repeated failures, route it to a separate dead-letter queue for inspection instead of losing it or blocking everything behind it.

Core concepts

Terminology varies slightly between systems, but the same handful of concepts recur:

  • Producer — the application or service that creates and sends a message.
  • Consumer — the application or service that receives and processes a message.
  • Broker — the server (or cluster of servers) that receives messages from producers, stores them, and makes them available to consumers. Kafka calls its servers "brokers"; RabbitMQ and Amazon MQ call themselves message brokers too.
  • Queue / topic — the named channel messages are sent to. "Queue" usually implies each message is handed to one consumer; "topic" (used by Kafka and by pub/sub systems generally) usually implies many consumers can independently read the same stream of messages.
  • Point-to-point vs. publish/subscribe — in a point-to-point queue, each message is delivered to exactly one consumer out of a pool (useful for distributing work across a set of workers). In pub/sub, a message published to a topic can be delivered to every subscriber independently (useful for fanning one event out to multiple interested systems). RabbitMQ's tutorials describe both patterns directly: "work queues" distribute tasks among competing workers, while its publish/subscribe tutorial sends messages to many consumers at once.
  • Delivery semantics — the guarantee a system makes about how many times a message might be delivered:
    • At-most-once: a message might be lost but is never redelivered/duplicated.
    • At-least-once: a message is never silently lost, but a consumer might see it more than once (for example, if it crashes after processing but before acknowledging).
    • Exactly-once: the hardest guarantee to provide end-to-end — the message is processed once and only once. Amazon's own SQS documentation states standard queues support "at-least-once message delivery" while FIFO queues support "exactly-once message processing."
  • Dead-letter queue (DLQ) — a separate queue that messages are automatically routed to after they've failed processing some number of times, so they stop clogging the main queue and can be inspected separately. AWS's SQS documentation describes this as isolating "unconsumed messages to determine why processing did not succeed," controlled by a redrive policy's maxReceiveCount.

Apache Kafka

Apache Kafka describes itself as a distributed "event streaming platform" rather than a traditional queue. Producers write events — records with a key, value, timestamp, and optional headers — to named topics. Each topic is split into partitions spread across brokers, which is how Kafka parallelizes reads and writes; events with the same key are routed to the same partition. Kafka's own documentation states that a consumer reading a single partition "will always read that partition's events in exactly the same order as they were written," though it does not guarantee ordering across different partitions of the same topic.

A defining difference from classic queues: in Kafka's pub/sub model, reading an event does not delete it. Events are retained according to a topic's configured retention period, so multiple independent consumer groups can replay the same topic from different points. Kafka's documentation also states it provides "the ability to process events exactly-once," achieved through mechanisms detailed in its design documentation (idempotent producers and transactions), rather than being the default behavior of every consumer.

RabbitMQ

RabbitMQ is a message broker built primarily around the AMQP protocol (RabbitMQ's own tutorials recommend AMQP 1.0 for new applications, while AMQP 0-9-1 remains its historical default). Its routing model is more granular than a plain queue: producers publish messages to an exchange, not directly to a queue, and RabbitMQ's own documentation defines exchanges as the entities "where messages are sent to," while queues are what "store messages that are consumed by applications." Bindings connect an exchange to one or more queues, optionally filtered by a routing key, and RabbitMQ supports several exchange types — direct, fanout, topic, and headers — each with different matching rules, which is what lets the same broker support both point-to-point work queues and fanout-style pub/sub.

On delivery guarantees, RabbitMQ's own reliability documentation is explicit: "Use of acknowledgements guarantees at least once delivery," while without consumer acknowledgements, "only at most once delivery is guaranteed." Publisher confirms provide the equivalent reliability guarantee on the sending side.

Amazon SQS

Amazon Simple Queue Service (SQS) is AWS's fully managed hosted queue. Per AWS's own developer guide, standard queues "support at-least-once message delivery," while FIFO queues support "exactly-once message processing and high-throughput mode," with strict ordering maintained within each message group. A message's lifecycle is straightforward: a producer sends it, a consumer receives it (after which it becomes invisible to other consumers for the duration of a configurable visibility timeout), and the consumer explicitly deletes it once processing succeeds — if it never deletes the message, the message becomes visible again for another consumer to try.

AWS's own quotas page states the maximum message size is 1,048,576 bytes (1 MiB), with larger payloads requiring AWS's SQS Extended Client libraries to store the body in Amazon S3 and pass a reference through the queue instead. The default message retention is 4 days, configurable up to 14 days. For dead-letter handling, AWS's own documentation describes a redrive policy with a maxReceiveCount setting: once a message has been received that many times without being deleted, SQS moves it to a separate dead-letter queue for inspection. SQS is commonly paired with AWS Lambda for serverless processing, where a queue buffers work and functions scale up automatically to drain it, and with Amazon SNS when a message needs to fan out to many subscribers at once — AWS's own comparison describes SQS as processing messages "through a single subscriber typically," with SNS added on top for fanout delivery.

Redis as a lightweight queue

Redis is best known as an in-memory data store (see Pandromeda's explainer on Redis for the basics), but its Streams data type doubles as a lightweight message queue. Per Redis's own documentation, a stream is an append-only log where each entry gets a unique ID and one or more field-value pairs, added with the XADD command. Consumer groups (created with XGROUP CREATE and read with XREADGROUP) split a stream's entries across multiple workers, similar in spirit to Kafka consumer groups, and delivered-but-unacknowledged entries sit in a per-group pending entries list until a consumer calls XACK. If a consumer crashes before acknowledging, another consumer can reclaim its pending entries with XCLAIM or XAUTOCLAIM — which is how Redis Streams provide at-least-once delivery, with the documentation noting that handlers should be written to be idempotent since reclaimed messages may be processed more than once.

This is a meaningfully different mechanism from Redis's older Pub/Sub feature, which simply fans a message out to whatever clients happen to be subscribed at that moment: there's no storage, so a subscriber that's offline when a message is published simply never sees it. Streams, by storing entries and letting consumers resume from any ID, are the closer analog to what Kafka or RabbitMQ do — just running inside Redis rather than as a dedicated broker.

SystemDelivery model (per vendor docs)OrderingTypical use case
Apache KafkaPub/sub; "ability to process events exactly-once" via idempotent producers/transactionsGuaranteed within a single partition; not guaranteed across partitionsHigh-throughput event streaming, log aggregation, feeding multiple independent consumer groups
RabbitMQAt-least-once with consumer acknowledgements; at-most-once without themNot explicitly guaranteed per queue in RabbitMQ's documentationFlexible routing (direct/fanout/topic/headers exchanges), task/work queues, request-reply
Amazon SQSStandard: at-least-once. FIFO: exactly-once processingStandard: best-effort. FIFO: strict, within a message groupFully managed queueing for AWS workloads, often paired with Lambda or SNS
Redis StreamsAt-least-once via consumer groups and pending-entries list (XACK/XCLAIM)Entries are ordered by ID within a streamLightweight queueing when a team already runs Redis and doesn't need a dedicated broker

Which one should you use?

There's no single right answer — the choice depends on what you're optimizing for, and each vendor's own documentation is the right place to confirm current limits and pricing before committing:

  • Reach for Kafka when you need very high throughput, want multiple independent systems to each read the full history of a stream, or are building event-sourcing or log-aggregation style pipelines.
  • Reach for RabbitMQ when you need flexible routing logic (fanout, topic matching, header-based routing) or are integrating with systems that already speak AMQP, MQTT, or STOMP.
  • Reach for Amazon SQS when you're already on AWS and want a managed queue with no servers to operate, especially alongside Lambda or SNS.
  • Reach for Redis Streams when you already run Redis for caching or data storage and need basic queueing — producer, consumer groups, acknowledgements, retries — without standing up a second piece of infrastructure.

Whichever broker you pick, it typically runs as its own service alongside the rest of your application when self-hosted, or as a managed service when you'd rather not operate the broker yourself.

What's next

If you're deciding whether your system needs a message queue at all, start by looking for the symptoms it solves: a request handler that's slow because it's doing work a user doesn't need to wait for, a downstream service that falls over during traffic spikes, or retry logic for failed operations scattered across your codebase instead of handled in one place. From there, the practical next step is almost always to read the broker's own getting-started tutorial — Kafka's, RabbitMQ's, or AWS's SQS developer guide all walk through standing up a producer and consumer in under an hour — rather than relying on secondhand comparisons, since defaults (retention periods, message size limits, acknowledgement behavior) are exactly the kind of detail that changes between versions and is worth confirming directly from the source.

Frequently asked questions

What is a message queue in system design?

A message queue is a component that temporarily stores messages sent by one service (a producer) until another service (a consumer) is ready to retrieve and process them, so the two sides never have to communicate directly or at the same time.

What is a Kafka message queue?

Apache Kafka describes itself as an event streaming platform rather than a traditional queue: producers write events to topics split into partitions, and unlike a classic queue, reading an event does not delete it, so multiple consumer groups can independently replay the same topic.

What is the difference between a message queue and a webhook?

A webhook pushes an HTTP request directly to another system the instant an event happens, with no broker holding it in between, so a down endpoint can miss it. A message queue stores the message durably in a broker until a consumer retrieves it, which is built-in retry and buffering that webhooks lack on their own.

What is the difference between at-least-once and exactly-once delivery?

At-least-once means a message is never silently lost but might be delivered and processed more than once. Exactly-once means it is processed once and only once. Per their own documentation, Amazon SQS standard queues are at-least-once while SQS FIFO queues are exactly-once, and RabbitMQ is at-least-once when consumer acknowledgements are used.

Can Redis be used as a message queue?

Yes. Redis Streams, documented at redis.io, support producers appending entries, consumer groups that split work across multiple workers, and acknowledgement via XACK, which together provide at-least-once delivery similar in spirit to Kafka consumer groups, without needing a separate dedicated broker.

What is a dead-letter queue?

A dead-letter queue is a separate queue that a broker automatically routes a message to after it has failed processing a configured number of times, so it stops blocking the main queue and can be inspected separately. Amazon SQS implements this with a redrive policy and a maxReceiveCount setting.

Sources

More on Message Queue →Message QueueApache KafkaRabbitMQAmazon SQSRedisSystem Design
Felix Moreau
Written byFelix Moreau

Felix Moreau writes Pandromeda's software coverage and how-to guides. He covers Windows, macOS and Linux updates, the apps people rely on, emulators and developer tools, and turns official documentation into clear, numbered steps that work on the current version.

More from Software & Guides

See all