Skip to content
We areTOP 1%

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

MediumConceptMessage Queues & Event Streaming
Track your progress
First attempt
Re-solve after a few days
Final pass before interviews

Answer

In a point-to-point queue, each message is processed by only one of several competing consumers, which spreads work across workers. In publish-subscribe, each message published to a topic is delivered to every subscriber, so several independent services can react to the same event.

  • Queue example: image-resizing jobs shared among a pool of workers.
  • Pub-sub example: an OrderPlaced event consumed separately by the billing, inventory and email services.
  • Kafka combines both: every consumer group receives all messages on a topic (pub-sub), while consumers within a group divide the partitions between them (queue).
  • Pub-sub adds fan-out and loose coupling, but it becomes harder to trace which services act on an event and in what order.

More in Message Queues & Event Streaming

Sign in to track your progress

Your checkboxes, streak and activity heatmap are saved to your account and sync across devices. It is free.
Sign in with email

New here? Create an account