Explain Message Queue vs Stream.
A message queue delivers each message once to a single consumer, while a message stream continuously broadcasts data events to multiple consumers in real time.
When to Use
- Message queues: Best for background jobs, order processing, or tasks that must run once reliably.
- Streams: Ideal for analytics, monitoring, and event-driven pipelines where multiple subscribers consume the same data.
Example
A message queue is like people waiting in line at a coffee shop (served one at a time). A stream is like a live radio broadcast where many listeners hear the same message instantly.
Want to master these concepts for interviews?
Explore Grokking System Design Fundamentals, Grokking the System Design Interview, Grokking Database Fundamentals for Tech Interviews, or Mock Interviews with ex-FAANG engineers.
Why Is It Important
Picking the right tool affects scalability.
Queues ensure reliable, ordered processing, while streams enable high-throughput, real-time insights.
Interview Tips
Be clear: queues = one consumer per message, streams = multiple consumers.
Reference tools like RabbitMQ, SQS, Kafka, or Kinesis to show practical knowledge.
Trade-offs
- Queues: Simple, reliable, but limited fan-out.
- Streams: Flexible, replayable, but harder to manage ordering and state.
Pitfalls
Using a queue where you need multiple consumers leads to duplication issues, while streams can be overkill for simple one-time tasks.
GET YOUR FREE
Coding Questions Catalog
$197

$78
$78