Interview Q&A / System Design

BeginnerQuick answer1 min readUpdated 3 Oct 2026

What is the difference between a message queue and publish-subscribe?

SHORT ANSWER

In a queue each message is processed by exactly one consumer from a group, which shares the work. In pub-sub each message is delivered to every subscriber, so many services can react to the same event.

Explain it simply

A queue is a ticket counter line: each customer is served by one clerk, and clerks share the line. Pub-sub is a college notice board or a WhatsApp group: one post, everybody subscribed sees it.

Queue (point to point): producers add jobs; several workers pull from the same queue; each job goes to one worker. Use it to distribute work, such as resizing uploaded images or sending emails.

Pub-sub (fan-out): a publisher sends an event to a topic; each subscriber gets its own copy. Use it to notify several systems about one fact, such as "order placed" going to billing, inventory and notifications.

Real systems blend them. Kafka uses consumer groups: within a group, partitions are divided like a queue; across groups, every group receives everything like pub-sub. SNS plus SQS is another combination: publish to a topic, and each subscriber has its own queue.

Example

Event: order 981 placed.

text
Queue "invoice-jobs": 3 workers -> order 981 handled by ONE worker.
Topic "order-placed": billing, inventory, email each get order 981.

What to say in the interview

"A queue distributes each message to one consumer for load sharing; pub-sub broadcasts each message to all subscribers for decoupled reactions. Kafka and SNS with SQS combine both, using consumer groups or per-subscriber queues."

#messaging#pub-sub

Related questions

Practise more System Design questions

Test your recall with short answers, then return to the detailed explanations when you need context.

Open System Design quick answers →

Get new questions like this by email

One short email when something new and useful lands. No spam, unsubscribe in one tap.

By subscribing you agree to the Privacy Policy.