Publisher-Subscriber
Publisher-Subscriber
is a design pattern that allows multiple components of a system to communicate asynchronously and decouple their dependencies.
- The publisher sends a message to a broker.
- One or more subscribers receive the messages from a broker.
- The broker can be a server or servers, with fault tolerance and load balancing.
- The broker uses queues or buffers to deliver the messages to the receivers.
- The queues or buffers are usually labeled as topics or channel names.
- The storage of the messages can be persistent or transient, depending on the requirements.
- Messages can use different formats: binary, JSON, XML, and text.
- Pros: Decoupling, scalability, and reliability.
- Popular systems: Kafka, AWS SNS, Azure Service Bus, RabbitMQ, and Redis.