Database / REDIS
What is the purpose of Redis Pub/Sub?
Pub/Sub lets clients broadcast messages on named channels to any number of subscribers listening at that moment, without Redis storing the message anywhere — it's a pure, ephemeral fire-and-forget messaging mechanism, not a durable queue.
# subscriber SUBSCRIBE notifications # publisher, from a different client PUBLISH notifications "New order received"
If no client is subscribed to a channel when a message is published, that message is simply lost — there's no backlog a late-joining subscriber can catch up on, which is the key difference from a Redis Stream. This makes Pub/Sub well suited to real-time notifications where only currently-connected clients need to know (like pushing a live update to open browser tabs), and poorly suited to anything where a message must be reliably delivered even to a consumer that wasn't listening at the exact moment it was sent.
More Related questions...
