...

/

Introduction to Pub-sub

Introduction to Pub-sub

Learn about the pub-sub system and its importance.

What is a pub-sub system?

Publish-subscribe messaging, often known as pub-sub messaging, is an asynchronous service-to-service communication method popular in serverless and microservices architectures. Messages can be sent asynchronously to different sub-systems of a system using the pub-sub system. All the services subscribed to the pub-sub model receive the message pushed into the system.

For example, when Cristiano Ronaldo posts on Instagram or shares a tweet, all of his followers are updated. Here Cristiano Ronaldo is the publisher, his post/tweet is the message and all the followers are subscribers.

Food for thought!

1.

What similarities and dissimilarities do pub-sub and queue have?

Show Answer
Q1 / Q2

Motivation

The hardware infrastructure of distributed systems consists of millions of machines. Using a pub-sub system to communicate asynchronously increases scalability. Producers and consumers are disconnected and operate independently, allowing us to scale and develop them separately. The decoupling between components (producers and consumers) allows scalability as adding or removing any component does not affect other components.

Let’s explore the use-cases where it is beneficial to have a pub-sub system.

Use-cases of pub-sub

A few use-cases of pub-sub are listed below:

  • Improved performance: The pub-sub system enables push-based distribution, alleviating the need for message recipients to check for new information and changes regularly. It encourages faster response times and lowers delivery latency. ...

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy