Lesson 9 of 14
23. Pub/Sub and Fan-Out

Memory card and where the analogy breaks

3 min read+10 XP

The memory card (tear this page out)

#QuestionMemory code
23.1Queue vs pub/sub?A job goes to one plumber; the news goes to every subscriber
23.2Topics and subscribers?Name the topic after what happened; let anyone who cares subscribe
23.3Consumer groups?Every team gets the paper; inside a team, the boys split the street
23.4Fan-out (write, read, hybrid)?Doorstep for most, the stall for the giants
23.5Event-driven architecture?Announce what happened; let whoever cares react
23.6Duplicates and ordering?Skip the second copy, and don't let yesterday's paper beat today's
23.7Outbox?Write it in the order book with the order; the relay posts it later

The whole chapter in one line: Publish facts once to a topic, let each interested service subscribe as a group, push to most and pull for the giants, make subscribers shrug off duplicates and stale events, and publish through an outbox.

Where the analogy breaks

  • A newspaper is the same for everyone. A feed is personal: fan-out builds a different list for every reader.
  • A reader can ignore yesterday's paper by looking at the date. A service needs explicit versions or sequence numbers to know which event is newer.
  • A paper agency doesn't keep last month's papers. A log like Kafka does, so a new subscriber can start from the past and replay history.

Quick check

Five questions on this chapter. Pick an answer, then check it.

quiz