Pub/Sub and queue look the same when you hear it for the first time.😱 Here is a simple explanation of what they are and the differences between them. In the illustration depicted below, 🔴 Messaging Queue: People come to the mall to shop. Before they check out, they must wait in the queue to complete the payment. Here, the mall is like a producer, producing people ( who have shopped and are ready to complete payment) who are sent to the queue to complete the payment. One by one, each person completes payment at the checkout counter. The checkout counter is like a consumer. As the queue grows ( more people join the line), more than one checkout ( one consumer ) is needed, and we will need to add more checkout counters ( more consumers). We have Producers, Queues, and Consumers. 🔴 Pub / Sub - Extending on the above example, after the checkout is completed, this customer data might be required by various services. For instance, in the image below, we have a real-time service that calculates how many people have completed the checkout. Hence, the checkout service has subscribed to receive this data. Likewise, marketing and inventory services might subscribe to receive this data. We have Producers, Topics, and Subscribers. 𝗣𝘂𝗯/𝘀𝘂𝗯:⏹️ The subscribers don’t have to reveal anything to the publishers. Messages are in the topic even after multiple subscribers consume it. Messages are sent to multiple subscribers simultaneously and asynchronously Message ordering and sending to various consumers is not guaranteed Producers and consumers have loose coupling 𝗤𝘂𝗲𝘂𝗲: ⏹️ Queues need to reveal who they are sending messages to Producers would put the messages in the queue, storing them until one of the consumers consumes them Producers put the messages in the queue, typically sent using some ordering and sequentially to a single receiver Message ordering and sending to consumers is guaranteed Producers and consumers have some sort of relationship #engineering #systemdesign #interview #productdevelopment #eventdrivenarchitecture
Informative comparison, illustrating the nuances between Pub/Sub and Queues.
Thanks for sharing this important difference 🔥
Simply put, Mahesh Mallikarjunaiah ↗️ 👌
Nicely explained
Pub-Sub is the backbone of modern applications! Thaks for sharing Mahesh Mallikarjunaiah ↗️
Very helpful! Mahesh Mallikarjunaiah ↗️
Mahesh Mallikarjunaiah ↗️ Clear and insightful breakdown! Understanding the nuances between Pub/Sub and queues is key for efficient data processing and system design.
14K I Top Programming Voice | Software engineer @TCS | Ex-Cognizant | software developer| Microservices | Api Design | Cloud Integrations | system design | Python | Open for collaboration
6moThanks for sharing