Explain Topic vs Queue.

In messaging systems, a topic broadcasts each message to all subscribers (publish-subscribe), while a queue delivers each message to only one consumer (point-to-point).

When to Use

Use a queue when you need only one worker to process each message (e.g., job execution). Use a topic when multiple independent services must consume the same event (e.g., sending notifications, logging, and analytics together).

Example

A topic is like a group chat—everyone sees the message.

A queue is like a private message sent to just one person.

Want to master these concepts for interviews?

Check out Grokking System Design Fundamentals, Grokking the System Design Interview, and Grokking Database Fundamentals for Tech Interviews. For hands-on practice, try Mock Interviews with ex-FAANG engineers.

Why Is It Important

Choosing between topics and queues determines system scalability, decoupling, and fault tolerance. The wrong choice can cause data loss or duplicated processing.

Interview Tips

In interviews, define both clearly, give a quick example, and explain pub-sub vs point-to-point.

Highlight trade-offs and when you’d use one over the other.

Trade-offs

  • Queue: Simpler, ensures one-time processing, but no broadcast.
  • Topic: Enables fan-out to many subscribers, but adds complexity and risk of duplication.

Pitfalls

Using a queue when multiple consumers need data causes missed information.

Using a topic for single-consumer tasks adds overhead. Also, undelivered messages in topics vanish if no subscriber is active.

TAGS
System Design Interview
System Design Fundamentals
CONTRIBUTOR
Design Gurus Team
-

GET YOUR FREE

Coding Questions Catalog

Design Gurus Newsletter - Latest from our Blog
Boost your coding skills with our essential coding questions catalog.
Take a step towards a better tech career now!
Image
One-Stop Portal For Tech Interviews.
Copyright © 2025 Design Gurus, LLC. All rights reserved.