What is Pub/Sub
Pub/sub (publish-subscribe) is a messaging pattern where publishers send messages to a named topic without knowing who will receive them, and subscribers receive all messages from topics they subscribe to.
How it works
A publisher writes a message to a topic. The message broker delivers a copy of that message to every subscriber of that topic. This is fan-out — one message reaches many consumers. The publisher and subscribers are completely decoupled.
This differs from a message queue, where each message goes to exactly one consumer. In pub/sub, every subscriber gets every message.
Where it is used
Kafka topics, Redis pub/sub, Google Cloud Pub/Sub, Amazon SNS, and RabbitMQ fanout exchanges all implement the pub/sub pattern. Common use cases include event notifications, real-time updates pushed via WebSockets, and decoupled microservice communication.
Why it matters
Pub/sub enables loose coupling. Adding a new subscriber is a configuration change — the publisher is unmodified. Removing a subscriber affects nothing. This makes systems extensible without coordination between teams.
For the full explanation including durable vs ephemeral subscriptions, see How Pub/Sub Works.