[2-min CS Concepts] A Rapid Introduction to the PubSub Communication Pattern

Publish Subscribe Pattern

Did you check the news today? Or receive an email newsletter from a company?

This type of communication is one way. Information flows from a publisher to the subscribers. The publisher creates information, the subscriber consumes information. Thus, computer scientists call this communication pattern publish and subscribe paradigm – pubsub.

When consuming news, you seek information about specific topics like sports or tech. You do not care too much about the source as long as it satisfies your needs. If you trust the information, understand it, and it is fresh, you keep using the news service.

A pubsub system is able to achieve this. You as a consumer register your information need. The system then delivers relevant information that satisfies your information need.

An example is Google News. Tell them your interested topics and your language preference. Google then pushes relevant news to your smartphone.

The strength of this communication paradigm is that it decouples sender and receiver. They do not even have to know each other. Have you ever received Google News article recommendations from sources you have never even heard from? Google’s pubsub system acts as a broker that takes care of organizing, finding, filtering, and delivering information.

For computers, this decoupling is also great. For instance, your smart home devices may subscribe to a weather service to react quickly. Your smart home device needs to know only one address – of the pubsub system. A huge advantage for systems with millions of participants such as the Internet of Things.

Deepen your code understanding skills with the Finxter web app.

Leave a Comment

Your email address will not be published. Required fields are marked *