{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreif4u73kzwrhlezjsond75hs6woaa2tup4x4jsszhvsk362h4p3tba",
"uri": "at://did:plc:5sgu76a53rz3n6unbykmovqy/app.bsky.feed.post/3mlogurcmokh2"
},
"description": "Pub/Sub (Publish-Subscribe) is a messaging pattern in which producers publish messages to a named channel (topic) without knowing who consumes them, and consumers subscribe to topics they care about without knowing who produced the messages. The pattern decouples producers from consumers, enabling fan-out, replay, and asynchronous processing.\n\n\nHow it differs from queues\n\n * Queue (point-to-point). Each message is consumed by one of N workers. Used for work distribution.\n * Pub/Sub (fan-out). Ea",
"path": "/engineering-glossary/pub-sub-messaging-pattern/",
"publishedAt": "2026-05-12T18:40:46.000Z",
"site": "https://sahilkapoor.com",
"tags": [
"Event-Driven Architecture",
"Redis",
"Microservices",
"Webhook",
"Idempotency"
],
"textContent": "**Pub/Sub (Publish-Subscribe)** is a messaging pattern in which producers publish messages to a named channel (topic) without knowing who consumes them, and consumers subscribe to topics they care about without knowing who produced the messages. The pattern decouples producers from consumers, enabling fan-out, replay, and asynchronous processing.\n\n## How it differs from queues\n\n * **Queue (point-to-point).** Each message is consumed by one of N workers. Used for work distribution.\n * **Pub/Sub (fan-out).** Each message is delivered to every interested subscriber. Used for event broadcast and integration.\n\n\n\nMany modern brokers support both patterns through different channel types or consumer-group semantics.\n\n## Common implementations\n\n * **Streaming brokers:** Apache Kafka, Redpanda, AWS Kinesis, Azure Event Hubs, NATS JetStream, Pulsar. Messages are durable, replayable, ordered within partitions.\n * **Cloud-managed:** Google Pub/Sub, AWS SNS (with SQS), Azure Service Bus topics, Cloudflare Queues.\n * **In-process / low-latency:** Redis Pub/Sub, NATS Core, ZeroMQ. Fast, often fire-and-forget.\n * **Traditional message brokers:** RabbitMQ, ActiveMQ, IBM MQ. AMQP, STOMP, MQTT protocols.\n\n\n\n## Delivery semantics\n\n * **At-most-once.** Messages may be lost but never duplicated.\n * **At-least-once.** Messages are never lost but may be redelivered; consumers must be idempotent.\n * **Exactly-once.** Each message processed once; expensive and often achieved through idempotency plus transactional offsets.\n\n\n\nš\n\n**Related Terms**\nEvent-Driven Architecture, Redis, Microservices, Webhook, Idempotency.",
"title": "Pub/Sub",
"updatedAt": "2026-05-13T19:14:40.749Z"
}