Real-time messaging · Fan-out · Backpressure
Pub/Sub
Publishers, topics, subscribers. Watch fan-out, backpressure, disconnect and replay — the dynamics every real-time system has to survive.
Every chat app, live dashboard, push notification, and stock ticker is built on the same primitive: a broker fans messages out from publishers to many subscribers in real time. This simulation runs that primitive at a slowed-down pace — turn up a publisher's rate, drop a subscriber's drain speed, and watch a queue climb until it's backpressured. Disconnect a consumer, flip the 'broker buffers' toggle, and see why the same gap can either replay cleanly or silently drop everything depending on one configuration choice.
Explore the activity to earn its passport stamp. Stamps record exploration, not mastery.
What’s happening under the hood
- ›Fan-out: one publisher writes once, the broker delivers to every subscriber whose subscription set matches the topic. Crucially different from point-to-point queues (where each message goes to one consumer). Redis pub/sub, Kafka consumer groups in broadcast mode, MQTT, and every WebSocket fan-out server implement this same shape — your phone gets the push notification because it subscribed to a topic, not because the server addressed it directly.
- ›Backpressure: the queue grows whenever inbound rate exceeds drain rate. In a single-machine sim this is a `q=12` indicator. In production it's a slow consumer melting a Kafka broker's disk, a WebSocket server running out of socket buffer, or a Lambda hitting its concurrency cap. The dominant production failure mode in real-time systems is not 'the message got lost' — it's 'one consumer is slow and now everyone is'.
- ›Delivery semantics live on a spectrum. At-most-once: fire and forget (UDP, raw WebSockets, default Redis pub/sub) — fast, simple, lossy under failure. At-least-once: the broker holds the message until the consumer acks, redelivering on disconnect (Kafka, RabbitMQ with acks, SQS) — durable, but the consumer must be idempotent because duplicates happen. Exactly-once: only achievable with transactional brokers, idempotent producers, and ack protocols (Kafka with transactions, Pulsar) — the most expensive guarantee in distributed systems, and the one most teams don't actually need.
Dig deeper
Phase 5 · Systems EngineeringThe concept you just explored is taught with full depth in the formal DURA curriculum.