# Publish-Subscribe (Pub/Sub)

> Send a message to a topic. All who listen get a copy.

**Field:** Software Development  
**Category:** Architecture  
**Also known as:** Pub/Sub, PubSub, Publish Subscribe, Topic

## Think of it like

Think of it like a radio station. It sends one show, and everyone tuned in hears it.

## Definition

Pub/sub is a way to send messages so that every listener gets a copy. Its full name is publish-subscribe. A publisher sends a message to a named topic. Any number of subscribers listen to that topic. Each of them gets its own copy of every message. The publisher does not know who, or how many, are listening.

## Example

Lucy's app publishes user signed up to a topic. The email service, the stats service and the welcome gift service each get a copy and act on it.

## Why it matters

One event can start many jobs. New listeners can join without a change to the sender.

## Common mistake

Using pub/sub when only one worker should do the job. Then each subscriber does it, and the buyer gets five emails.

## Three principles

- **Send to a topic.** Not to a person.
- **Everyone gets a copy.** Each subscriber.
- **Sender stays blind.** Who listens is not its business.

## Related terms

- [Message Queue](https://learn.benibix.com/term/development/message-queue)
- [Observer Pattern](https://learn.benibix.com/term/development/observer-pattern)
- [Event Bus](https://learn.benibix.com/term/development/event-bus)
- [Event-Driven Architecture](https://learn.benibix.com/term/development/event-driven-architecture)
- [MQTT Protocol](https://learn.benibix.com/term/development/mqtt)

## Told apart from

- [Message Queue vs Pub/Sub](https://learn.benibix.com/compare/message-queue-vs-pub-sub): A message queue and pub/sub both pass messages between parts of a system, but they hand them out in two different ways. In a queue, each message goes to just one worker. So a job is done once. In pub/sub, every subscriber gets its own copy. So one event can start many jobs. Use a queue for work and pub/sub for news.

---

Source: https://learn.benibix.com/term/development/publish-subscribe
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
