Skip to content
StackDecode
System Design
9. Message Queues and Event-Driven SystemsAnimated

Publish-Subscribe Pattern

Publishers send to topics; many subscribers receive.

The idea

The publisher does not know the subscribers. Every subscriber gets a copy.

Watch it work

Press play, pause, or step through. Some animations have settings you can change.

ProducerEvent brokerBillingEmailAnalytics
  • client
  • gateway / proxy
  • service
  • cache
  • data store
  • queue / stream

A service publishes an event: "OrderPlaced".

step:
1/4
at:
Producer
1/8

The green dot is a request moving through the system.

Step by step

  1. 1Subscribers register for a topic
  2. 2A publisher sends a message
  3. 3The broker copies it to each subscriber
  4. 4Subscribers process independently

Where it is used

Notifications and events.

Watch out for

Slow subscribers need their own buffering.

Related