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.
- 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
- 1Subscribers register for a topic
- 2A publisher sends a message
- 3The broker copies it to each subscriber
- 4Subscribers process independently
Where it is used
Notifications and events.
Watch out for
Slow subscribers need their own buffering.