- Published on
Pub/Sub vs Message Queues — Explained the Way Engineers Should Actually Learn It
- Authors

- Name
- Mehdi Akiki
Most explanations of queues and pub/sub start the wrong way.
They begin with buzzwords: broker, consumer group, durability, event streaming. And they skip the only question that actually matters:
Why did engineers invent these tools in the first place?
If you don't understand the problem they solved, the tools never really stick in your brain. So let's start earlier.
Contents
- Before queues existed
- The world before queues
- Why queues won
- What a queue actually is
- But queues did not solve everything
- What pub/sub is really for
- Why the difference matters
- The simplest mental model
- Why beginners get confused
- In real systems, both usually appear
- The takeaway
1. Before queues existed
Imagine early humans hunting.
For a long time they could gather fruit and survive. But eventually fruit became scarce, and humans needed another strategy. They had to coordinate work: track animals, chase them, trap them, divide tasks.
That forced the invention of tools. Not because tools were elegant. Because nature forced the problem.
Software architecture evolved the same way.
Queues and pub/sub did not appear because engineers love patterns. They appeared because systems started to break when scale increased.
Before these tools existed, systems were much simpler. A request arrived. The server handled it. The server finished the work. Done. One request, one response, one piece of work completed.
This worked perfectly — until it didn't.
2. The world before queues
Early web applications followed a simple model:
- A user sends a request.
- The server handles it immediately.
- The server returns a response.
Everything happened synchronously. For small systems this worked beautifully.
But then real applications started doing heavier work:
- Sending emails
- Processing payments
- Generating reports
- Resizing images
- Syncing data with other systems
Now the request handler had a problem. It had to do too many things before replying. If one step was slow, the entire request became slow. Users started waiting seconds instead of milliseconds.
Then another problem appeared.
What happens if the server crashes in the middle of the work? The task disappears. The system has lost work.
At small scale this was annoying. At large scale it became unacceptable.
Engineers needed a new tool. That tool became the queue.
3. Why queues won
Queues solved two problems that synchronous systems could not solve well.
First: they separated accepting work from doing work.
Instead of doing everything inside the request, the server could simply say: "this task needs to be done" and place the task into a waiting line. Workers could process tasks later.
Second: queues created a buffer.
If 10,000 jobs arrived suddenly, the system didn't crash. The jobs simply waited in line. Workers processed them at a controlled pace.
That simple idea — a waiting line for work — changed how large systems were built. Queues became the default solution whenever a system needed to handle background work safely.
Not because queues are trendy. Because the nature of the problem demanded them.
4. What a queue actually is
A queue is not magic. It is just a waiting line.
Tasks enter the line. Workers pull tasks from the line. Each task is meant to be handled once by one worker.
Examples make this clearer. If your system needs to:
- Send emails
- Process payments
- Generate invoices
- Resize uploaded images
- Pack and ship orders
These are jobs. They must be completed. They should not disappear if a server crashes. They should not overload the system if too many arrive at once.
Queues solve this naturally. They hold the work until workers are ready.
That is why queues appear everywhere in real systems.
5. But queues did not solve everything
Once engineers started using queues widely, another kind of problem appeared.
Some messages were not tasks. They were events.
An event is simply something that happened in the system:
- A user signed up
- A post was liked
- A comment was posted
- An order was created
These are not jobs waiting to be completed. They are facts about the system. And many different services may care about those facts.
This created a different need. Instead of giving one worker a job, the system needed to tell many listeners that something happened.
Queues were not designed for that. Trying to broadcast events through queues quickly became awkward.
That is where publish–subscribe systems appeared.
6. What pub/sub is really for
Pub/sub systems solve a different problem from queues. They allow one service to say: "this happened" — and let many other services react independently.
Think of it as an announcement. One message enters the system. Many consumers may receive it. Each consumer decides what to do.
- Some might store analytics.
- Others might send notifications.
- Others might update search indexes.
The important difference is this:
Queues are about completing work. Pub/sub is about spreading information.
That distinction is much more useful than memorizing tool names.
7. Why the difference matters
If you misunderstand the nature of the message, you pick the wrong architecture. Two examples make this concrete.
Sending password reset emails
A user requests a password reset. This message means: "send an email." That is a task. One worker should perform it. If the worker crashes halfway through, the system should retry. If thousands of emails need to be sent, they should wait their turn instead of crashing the server.
A queue fits perfectly here. The system accepts the job, places it in line, and workers process it reliably.
A user likes a post
Now imagine a user clicking "like." Several systems might care:
- Push notifications
- Activity feeds
- Analytics
- Recommendation engines
This message is not a job. It is an event. Something happened. Multiple systems may want to react.
That is where pub/sub fits better. The system announces the event once, and any interested service can respond.
8. The simplest mental model
After years of explaining these systems, the simplest explanation still wins:
Queues line up work. Pub/sub spreads events.
Queues are about completion. Pub/sub is about distribution.
If you remember that distinction, the architecture decisions become far clearer.
9. Why beginners get confused
Most tutorials start with tooling. Kafka. RabbitMQ. SQS. SNS.
But tools are not the important part. The important part is understanding what problem the system is solving.
Once you understand that queues exist to manage unfinished work and pub/sub exists to distribute events, the tooling becomes almost secondary. You can swap technologies easily. What matters is the pattern.
10. In real systems, both usually appear
Large systems rarely choose only one. Instead they combine both patterns.
An order service might publish an event: order_created. Several services hear about the event through pub/sub. Then each service creates its own internal jobs:
- The notification service queues email jobs.
- The billing service queues payment processing.
- The warehouse service queues fulfillment tasks.
Pub/sub distributes the event. Queues manage the work. Together they form a clean architecture.
This pattern became standard because it mirrors how real systems behave. Events happen in the world. Work must be completed afterward. Pub/sub models the events. Queues manage the work.
Once you see systems through that lens, distributed architectures stop looking mysterious. They start looking practical.
11. The takeaway
Queues and pub/sub are not competing tools. They exist because engineers faced two different problems.
Sometimes systems must finish work reliably. Sometimes systems must spread information widely.
Queues solve the first problem. Pub/sub solves the second.
Understanding that difference is far more valuable than memorizing technology names. Because in system design, the best architectures are rarely chosen by fashion. They are chosen because the nature of the problem forces the tool.
I build and scale reliable production systems. Open to full-time and freelance work with U.S.-based teams that value ownership and execution.
Got something in mind?
Book a Discovery Call