15 YouTube views, likes subscribers in 10 minutes. Free!
Get Free YouTube Subscribers, Views and Likes

What is the Publisher Subscriber Model?

Follow
Gaurav Sen

Microservices benefit from loose data coupling, which is provided by a publish subscribe model. In this model, events are produced by a publishing service and consumed by downstream services.

Designing the micro service interactions involves event handling and consistency checks. We look into a pubsub architecture to evaluate it's advantages and disadvantages compared to a request response architecture.

This type of architecture relies on message queues to ensure event passing. An example would be rabbitMQ or Kafka. The architecture is common in real life scenarios and interviews.

If there is no strong consistency guarantee to made for transactions, an event model is good to use in microservices. Here are the main advantages:

00:00 Problem Statement
00:49 Asynchronous Events
01:58 Publisher Subscriber Model
03:04 Advantages of Event Systems
05:45 Drawbacks of Event Systems
10:22 Conclusion
11:22 Thank you!

1) Decouples a system's services.
2) Easily add subscribers and publishers without informing the other.
3) Converts multiple points of failure to single point of failure.
4) Interaction logic can be moved to services/ message broker.

Disadvantages:
1) An extra layer of interaction slows services
2) Cannot be used in systems requiring strong consistency of data
3) Additional cost to team for redesigning, learning and maintaining the message queues.

This model provides the basis for event driven systems.

Looking to ace your next interview? Try this System Design video course!
https://interviewready.io

Course chapters:
1) Design an email service like Gmail
2) Design a rate limiter
3) Design an audio search engine
4) Design a calling app like WhatsApp
5) Design and code a payment tracking app like Splitwise
6) Machine coding a cache
7) Low level design of an event bus

The chapters have architectural diagrams and capacity estimates, along with subtitled videos. Use the coupon code of 'earlybird' to get a 20% discount.

Code: https://github.com/codingparrot/Low...

References:
https://docs.oracle.com/cd/B10501_01/...
https://aws.amazon.com/pubsubmessag...
https://en.wikipedia.org/wiki/Publish...

posted by forvitnukn