Redis is often already in the stack, so it is tempting to use its pub/sub feature for every kind of asynchronous message. That works well for some jobs and fails silently for others. The difference comes down to one property: does the system remember a message after it is sent?

How Redis Pub/Sub behaves

With pub/sub, a publisher sends a message to a channel and Redis immediately forwards it to every client subscribed to that channel at that moment. Then the message is gone.

plain text
publisher ──PUBLISH chat:42──▶ Redis ──▶ subscriber A (connected)
                                      ──▶ subscriber B (connected)
                                      ✕   subscriber C (restarting: never receives it)

This gives pub/sub its strengths and its limits:

  • Fire and forget. Messages are not stored. A subscriber that is disconnected, restarting or slow misses messages that were published in the meantime.
  • No acknowledgement. The publisher learns how many clients received the message, not whether any of them processed it.
  • Fan-out to everyone. Every subscriber gets every message. There is no built-in way to share work between consumers.
  • Very low latency. There is almost nothing between publish and delivery.

How durable queues behave

A durable queue (or log) stores messages until a consumer confirms it has handled them. Redis Streams, RabbitMQ, Amazon SQS, Kafka, NATS JetStream and database-backed job queues all fall into this family, with different trade-offs.

What they have in common:

  • Persistence. A message survives consumer restarts, and with appropriate configuration, broker restarts too.
  • Acknowledgement. A message is considered done only after the consumer acknowledges it. Unacknowledged messages are redelivered.
  • Competing consumers. Work can be spread across a group of workers, each message handled by one of them.
  • At-least-once delivery. Because of redelivery, a message can be processed more than once, so handlers must be idempotent.

With Redis Streams, that looks like this:

bash
# Producer appends to the stream
XADD outbound-messages * conversation_id 42 body "Your order has shipped"

# Create a consumer group once
XGROUP CREATE outbound-messages senders $ MKSTREAM

# Each worker reads new messages for the group
XREADGROUP GROUP senders worker-1 COUNT 10 BLOCK 5000 STREAMS outbound-messages >

# After handling a message successfully
XACK outbound-messages senders 1731744000000-0

Messages that a crashed worker read but never acknowledged stay in the group's pending list, where another worker can claim them with XAUTOCLAIM.

The decision in one table

QuestionPub/SubDurable queue / stream
Is it acceptable to lose a message?YesNo
Should every consumer get every message?YesUsually no: one worker per message
Must work survive restarts and deploys?NoYes
Need retries and dead-lettering?NoYes
Latency budgetLowestLow, with a little more overhead

Where pub/sub is the right tool

Pub/sub fits ephemeral notifications where the source of truth lives elsewhere and a missed message is harmless or self-healing:

  • Telling WebSocket gateways that a conversation changed, so connected clients refresh. A client that misses it reloads state on reconnect anyway.
  • Cache invalidation hints across instances, where entries also have a TTL.
  • Presence and typing indicators.

The common thread: the message says "something changed, go look", and the real data is safely in a database.

Where you need a durable queue

Use a queue or stream whenever the message is the work:

  • Sending emails, SMS or channel messages.
  • Charging payments or calling partner APIs.
  • Processing uploads, imports and reports.
  • Any step in a workflow where skipping it leaves the system in a wrong state.

Using pub/sub for these produces the classic failure: everything works in development, and then a deploy restarts the workers and a few hundred notifications vanish without an error anywhere.

Combining them

Realtime systems often use both. A typical shape:

plain text
API ──(transaction)──▶ database + outbox row
                            │
                outbox relay │
                            ▼
                    durable queue ──▶ workers (send, charge, call partners)
                            │
                            └──▶ pub/sub "changed" event ──▶ WebSocket gateways ──▶ clients

The durable path guarantees the work happens. The pub/sub path makes the UI feel instant. If a pub/sub message is lost, a client is a little stale until its next fetch; nothing is lost.

Getting the event out reliably

One more trap: writing to the database and then publishing to a queue are two separate operations. If the process crashes between them, the database says the order exists but no worker ever hears about it.

The transactional outbox fixes this. Write the event to an outbox table in the same transaction as the business data. A relay process reads the outbox and publishes to the queue, marking rows as sent. Combined with idempotent consumers, this gives you reliable at-least-once processing without distributed transactions.

Summary

  • Pub/sub is a broadcast with no memory: great for "something changed" hints, wrong for work that must happen.
  • Durable queues and streams remember messages until they are acknowledged, and redeliver them on failure.
  • At-least-once delivery means consumers must be idempotent.
  • Use an outbox so that writing data and emitting the event cannot get out of sync.

Picking the right primitive early is cheap. Discovering in production that your notification system has been dropping messages on every deploy is not.