23. Pub/Sub and Fan-Out
1
The picture to keep in your head2
23.1 What's the difference between a queue and pub/sub?3
23.2 What are topics and subscribers?4
23.3 What are consumer groups?5
23.4 What are the fan-out strategies?6
23.5 What is event-driven architecture?7
23.6 How do you handle duplicates and ordering?8
23.7 How do you publish events reliably (the outbox pattern)?9
Memory card and where the analogy breaks10
Practice: five levels11
Interview questions12
Solutions13
Sources14
Code lab23. Pub/Sub and Fan-Out
Sources
3 min read+10 XP
Source notes
- Pub/sub, topics, subscriptions and consumer groups: Apache Kafka documentation; Google Cloud Pub/Sub documentation; Amazon SNS documentation (SNS to SQS fan-out).
- Fan-out on write with special handling for high-follower accounts in social timelines: Raffi Krikorian (Twitter), "Timelines at Scale", QCon San Francisco 2012 (InfoQ).
- Transactional outbox pattern: Chris Richardson, microservices.io, "Pattern: Transactional outbox"; Debezium documentation, outbox event router.
- Event notification vs event-carried state transfer: Martin Fowler, "What do you mean by 'Event-Driven'?", 2017.
- Follower counts, release volumes, write rates and reader numbers are illustrative assumptions; arithmetic computed 2026-10-08.
- Level 3 and Level 4 code: tested 2026-10-08 (
code/ch23_pubsub.py, all checks pass).