Hey developers! π
Welcome back to our journey through communication patterns and distributed systems.
When a customer places an order online, they usually see something simple:
"Your order has been confirmed."
From the customer's perspective, the story ends there.
Behind the scenes, however, an entire chain of events begins.
The inventory must be updated.
The payment must be recorded.
The customer should receive an email.
Analytics dashboards need updating.
Fraud detection systems may need to run.
Loyalty points might need to be awarded.
Shipping labels may need to be generated.
What appears to be a single action is often dozens of actions happening across multiple systems.
And how those systems communicate determines whether a company can scale smoothlyβor spend years fighting architectural bottlenecks.
This is where the Publish-Subscribe (Pub/Sub) pattern enters the picture.
The Architecture That Works Until It Doesn't
Imagine an e-commerce platform processing:
50 Orders Per Day
A customer places an order.
The Order Service directly calls:
Inventory Service
Email Service
Analytics Service
Billing Service
Shipping Service
Everything works.
The architecture feels simple.
The team ships features quickly.
Everyone is happy.
At first.
The Hidden Dependency Problem
The challenge isn't visible immediately.
It's hidden inside the dependency chain.
Order Service
βββ Inventory
βββ Email
βββ Analytics
βββ Billing
βββ Shipping
Every new business requirement adds another dependency.
Every dependency adds another failure point.
Over time:
Order Service
β
Becomes The Center
Of Everything
The architecture slowly becomes more fragile.
Not because developers made mistakes.
Because the business kept growing.
A Real Failure Scenario
Imagine this workflow:
create_order()
reserve_inventory()
send_confirmation_email()
update_analytics()
Everything looks reasonable.
Until one day:
Email Service Fails
Now what happens?
In many systems:
Email Failed
β
Workflow Stops
β
Analytics Never Runs
β
Customer Experience Suffers
A non-critical system suddenly affects a critical workflow.
The services are technically separate.
Operationally, they are tightly connected.
This is known as:
Tight Coupling
The Postmortem Nobody Wants to Write
A surprisingly common production incident looks like this:
What Happened?
A third-party email provider experienced elevated latency.
Impact
Order creation response times increased from:
200ms
to:
8β15 Seconds
Business Impact
- Customers abandoned checkout
- Conversion rates dropped
- Support tickets increased
- Revenue was affected
Root Cause
The Order Service waited for the Email Service before responding.
Architectural Problem
The platform treated a non-critical task as a critical dependency.
Notice something important.
The email wasn't required to create the order.
The order should have succeeded regardless.
The architecture created the outage.
Not the email provider.
A Different Way of Thinking
Most traditional systems think like this:
Do This
β
Do That
β
Do Another Thing
The workflow is command-driven.
Event-driven systems think differently.
Something Happened
β
Whoever Cares Can Respond
That shift sounds small.
Architecturally, it's enormous.
Enter Publish-Subscribe
Instead of directly calling every downstream service, the Order Service publishes an event.
Order Service
β
Order Created
β
Message Broker
β
Inventory
Email
Analytics
Billing
Shipping
The Order Service now has only two responsibilities:
Create Order
Publish Event
Done.
It no longer cares:
- Who consumes the event
- How many consumers exist
- What consumers do
- When consumers process it
It simply announces a fact:
Order Created
Anyone interested can react.
Think of Pub/Sub Like a News Agency
Imagine a news organization.
A reporter publishes breaking news.
Breaking News
The reporter doesn't individually call:
- Television stations
- Newspapers
- Radio stations
- Websites
- Mobile apps
Instead:
Reporter
β
News Agency
β
Subscribers
Each subscriber receives the information independently.
That's exactly how Publish-Subscribe works.
The producer publishes.
Subscribers decide whether they care.
What Is Publish-Subscribe?
Publish-Subscribe is a messaging pattern where producers publish events to a broker, and consumers subscribe to events they are interested in.
The producer and consumer never communicate directly.
Producer
β
Broker
β
Consumer
This creates:
Loose Coupling
One of the most valuable properties in modern software architecture.
The Message Broker Becomes the Traffic Controller
A broker sits between producers and consumers.
Examples include:
- Apache Kafka
- RabbitMQ
- Amazon SNS
- Amazon SQS
- Google Pub/Sub
- NATS
The broker receives events and distributes them.
Publisher
β
Broker
βββ Inventory
βββ Email
βββ Billing
βββ Analytics
βββ Fraud Detection
Services no longer need direct knowledge of one another.
The broker becomes the communication hub.
A Visual Mental Model
Direct Communication
Order Service
βββ Inventory
βββ Email
βββ Billing
βββ Analytics
βββ Shipping
Every new feature creates another dependency.
Publish-Subscribe
Order Service
β
βΌ
Order Created
β
βΌ
Broker
βββ Inventory
βββ Email
βββ Billing
βββ Analytics
βββ Shipping
The producer has one dependency.
The broker.
Nothing more.
Why Business Leaders Love Pub/Sub
Businesses don't buy architectures.
They buy outcomes.
Publish-Subscribe creates outcomes executives feel directly.
Faster Feature Delivery
Imagine marketing wants a loyalty points system.
In a tightly coupled system:
Modify Order Service
Retest Order Service
Redeploy Order Service
Risk Order Service
In Pub/Sub:
Create Loyalty Consumer
Subscribe To Order Created
Deploy Independently
The order workflow remains untouched.
New features can be delivered with lower risk.
Reduced Revenue Risk
Suppose Analytics fails.
With Pub/Sub:
Orders Continue
Payments Continue
Customers Continue
Only analytics is affected.
The failure becomes isolated.
The blast radius stays small.
Better Organizational Scaling
As companies grow:
Payments Team
Inventory Team
Growth Team
Customer Team
Data Team
Each team can independently subscribe to events.
Teams become less dependent on one another.
Development velocity increases.
Why Developers Love Pub/Sub
Developers eventually discover a painful truth:
Scaling dependencies is often harder than scaling traffic.
Pub/Sub helps solve that problem.
Loose Coupling
Without Pub/Sub:
Order Service
β
Inventory
β
Email
β
Analytics
With Pub/Sub:
Order Service
β
Broker
β
Consumers
The producer only knows one thing:
Publish Event
Everything else becomes optional.
Independent Deployments
Teams can build:
Fraud Detection
Recommendation Engine
Customer Segmentation
without touching the ordering system.
This dramatically reduces deployment risk.
Better Resilience
Imagine Billing Service crashes.
The broker retains events.
When Billing returns:
Order Created #1001
Order Created #1002
Order Created #1003
can still be processed.
The system recovers gracefully.
The Hidden Challenges
Many architecture articles stop at the benefits.
Real systems don't.
Every architectural gain introduces tradeoffs.
Challenge #1: Eventual Consistency
In synchronous systems:
Order Created
Inventory Updated
Response Returned
Everything happens immediately.
In Pub/Sub:
Order Created
Response Returned
Inventory Updated Later
There is now a delay.
Different systems may temporarily disagree.
This is called:
Eventual Consistency
A fundamental reality of distributed systems.
Challenge #2: Duplicate Events
Networks fail.
Retries happen.
Consumers crash.
The same event may arrive twice.
Order Created #123
Order Created #123
Consumers must be:
Idempotent
Otherwise:
Inventory Reduced Twice
Customer Charged Twice
Bad days begin.
Challenge #3: Observability
Tracing a monolithic workflow is straightforward.
Request
β
Response
Tracing an event-driven workflow is not.
Order Created
β
Inventory Updated
β
Billing Generated
β
Email Sent
β
Analytics Updated
One user action may generate dozens of events.
Understanding failures becomes significantly harder.
This is why mature organizations invest heavily in:
- Distributed tracing
- Correlation IDs
- Event monitoring
- Audit logs
How Modern Platforms Actually Think
The most scalable architectures rarely ask:
Which service should call which?
Instead they ask:
What business events exist?
Examples:
Order Created
Payment Authorized
Shipment Created
Invoice Generated
User Registered
Subscription Renewed
These events become the language of the business.
Systems are built around reacting to those events.
The architecture evolves alongside the organization.
The Architect's Lesson
Publish-Subscribe teaches a powerful principle:
Growth becomes easier when systems communicate through events instead of dependencies.
The evolution often looks like this:
Direct Calls
β
βΌ
Too Many Dependencies
β
βΌ
Publish-Subscribe
β
βΌ
Loose Coupling
β
βΌ
Independent Scaling
The goal isn't messaging.
The goal is adaptability.
TL;DR Quick Recap
- Publish-Subscribe is an event-driven communication pattern.
- Producers publish events without knowing who consumes them.
- Consumers subscribe to events they care about.
- Message brokers distribute events between systems.
- Pub/Sub reduces coupling between services.
- Teams can deploy independently.
- Failures become more isolated.
- Eventual consistency and observability become important challenges.
- Modern scalable platforms are often built around business events.
Final Thoughts: Systems That Speak in Events π§
Many growing companies eventually discover the same lesson.
Direct communication feels simple.
Until growth arrives.
Every new dependency creates risk.
Every new integration increases complexity.
Publish-Subscribe changes the conversation.
Instead of asking:
Who should I call?
systems begin asking:
What happened?
That shiftβfrom commands to eventsβis one of the most important architectural transitions in modern software engineering.
Because the companies that scale successfully are rarely the ones with the most services.
They're the ones with the clearest events.
A Little Engineering Joke to End On π
Why did the Order Service stop calling everyone directly?
Because it got tired of being the group project coordinator.
Frequently Asked Questions
What is Publish-Subscribe?
Publish-Subscribe (Pub/Sub) is a messaging pattern where producers publish events and consumers subscribe to the events they care about.
What problem does Pub/Sub solve?
It reduces direct dependencies between services, improving scalability, resilience, and team autonomy.
What is a message broker?
A message broker is an intermediary system that receives, stores, and distributes events between producers and consumers.
Is Pub/Sub synchronous or asynchronous?
Most Pub/Sub systems are asynchronous.
Producers publish events and continue without waiting for consumers.
Why is Pub/Sub popular in microservices?
Because it enables loose coupling, independent deployments, better fault isolation, and easier organizational scaling.
What are the downsides of Pub/Sub?
Common challenges include:
- Eventual consistency
- Duplicate event handling
- Increased operational complexity
- Difficult observability and debugging
Key Takeaways
- Publish-Subscribe is an event-driven communication pattern.
- Producers publish facts rather than calling services directly.
- Consumers independently react to events.
- Message brokers decouple producers from consumers.
- Pub/Sub improves scalability, resilience, and team autonomy.
- Eventual consistency is a normal part of the model.
- Observability becomes increasingly important.
- Modern architectures often scale by thinking in events rather than direct dependencies.
If you found this article useful, share it with fellow backend engineers, system architects, platform engineers, and distributed systems enthusiasts exploring communication patterns at scale.
About the Author
Anik Sikder is a Software Engineer specializing in Backend Systems, SaaS Architecture, Cloud Infrastructure, Python, Django, FastAPI, distributed systems, and scalable software engineering.
He writes about system design, networking, distributed systems, cloud computing, software architecture, and modern engineering practices.



