educative.io

Educative

Why do we use seperate queue for a topic?

While designing the pub-sub system we are creating a seperate distributed queue for every topic, why? why can’t we have a general distributed queue where any topic can be pushed and at the end of the queue we send the topic to those who have subscribed

Hi @Raghu_paavan_V_V_S , If we maintain a generic queue that contains all topics, the messages for every topic will be accessible to all consumers. It will be a security concern so it is a better and safe approach to maintain a queue for each topic.

Additionally using a separate queue for each topic give us more leverage in terms of scalability and fault-tolerance. We can serve different topics from differnet servers (few topic can be busier than others etc.) and failure of one queue will not impact all customers.