The Synchronous Coupling Problem
order checkout calling everything inline:
POST /checkout ──► charge card ──► reserve stock ──► send email
│ │ │
if email svc is down → WHOLE CHECKOUT FAILS
if stock svc is slow → user stares at spinner
every synchronous dependency:
- adds latency to the critical path
- extends the failure blast radius
- couples deploy/scaling schedules between teams
The Async Alternative
insert a broker; separate MUST-HAPPEN-NOW from SHOULD-HAPPEN-SOON:
POST /checkout ──► core txn: payment + reservation ──► 200 OK
│
▼ event: "OrderPlaced"
[broker: kafka/rabbitmq/sqs]
│ consumed by:
├─ email service (whenever)
├─ analytics (whenever)
└─ loyalty points (whenever)
email service down? events WAIT. checkout unaffected.
new consumer (fraud checks)? subscribe — zero changes upstream.
The Three Gifts of Messaging
| Gift | Mechanism |
|---|---|
| Temporal decoupling | Producer/consumer need not be alive simultaneously |
| Load leveling | Spikes buffer as queue depth, not service collapse |
| Fan-out broadcasting | One event feeds N consumers independently |
plus a fourth, quietly:
RETRY SEMANTICS come built-in — failed consumption returns
to queue with backoff instead of being lost in an HTTP timeout.
When NOT to Use It
✗ USER WAITS FOR THE RESULT:
"check password" via queue = absurd UX
✗ STRICT CONSISTENCY ACROSS STEPS:
debit+credit atomically → transactions/sagas,
not fire-and-forget messages
✗ SIMPLE REQUEST/RESPONSE:
two services, one call, low volume → HTTP/gRPC is simpler.
messaging adds operational surface (broker ops, monitoring,
ordering/duplicate handling) — it must EARN its place.
rule: async is for work whose DELAY is acceptable.
classify each interaction honestly before choosing.
The Cost Ledger
adopting messaging means accepting:
- EVENTUAL consistency (state converges over time)
- DUPLICATE deliveries possible (at-least-once) → idempotent consumers
- ORDERING caveats (per-partition only, usually)
- DEBUGGING across time (traces span producer→queue→consumer)
- BROKER as critical infrastructure (it down ≠ nothing works)
every one has established patterns — the following lessons
cover them all. but they ARE real engineering costs,
not free architecture candy.
Interview Framing
“Design order processing” scored shape: split flow into synchronous CORE (payment/reservation — user waits) vs async SIDE-EFFECTS (email/analytics/loyalty), place the broker between, name the three gifts when justifying, then volunteer ONE cost with mitigation (“at-least-once → idempotent consumers”). Knowing when NOT to queue is half the signal.
Premium Content
Unlock Why Messaging Exists and all premium lessons with a subscription.
All premium lessons
Ad-free experience
Priority support
From ₹199.99/year — See plans