Sync vs Async: Block or Delegate?
In a distributed system, how your services talk to each other defines the performance perceived by the user. Should you make them wait on the phone (Synchronous) or send them a text (Asynchronous) so they can go about their lives?
The Duel: Call vs Text
You call a friend for info. As long as they don't answer, you stay with your ear glued to the phone. You can't do anything else.
Impact: Time stops for the caller.
- Blocking: The client waits for the response (Request/Response).
- Simple to understand and debug.
You send a message. You put down your phone and go play sports. The answer will arrive when it arrives (Fire & Forget).
Impact: You are freed immediately.
- Non-blocking: The client continues their life immediately.
- Ideal for long tasks (sending emails, PDF generation).
Flow Visualization

The Magic Solution: Queues & Workers
The "Producer / Consumer" Pattern
How to do async properly? We don't let the web server do the heavy lifting. We use an intermediary.
When to choose what?
| Use SYNCHRONOUS when... | Use ASYNCHRONOUS when... |
|---|---|
✔ The client needs the answer right away (e.g., Login, Google Search). | ✔ The action is slow (> 200ms) or heavy (Video processing, Analytics). |
✔ It is a simple Read (GET) operation. | ✔ You want to smooth out a traffic spike (Load Leveling) to avoid crashing your DB. |
✔ Transactional logic is complex (if step 2 fails, step 1 must rollback). | ✔ You don't need an immediate response (Fire and Forget). |
In Interviews (System Design)
Don't just say "I use a queue". Explain why.
Flash Quiz
Your Turn
Mission: Newsletter Sending Architecture
You have to send 1 million emails. If you do a `for` loop synchronously, your server will timeout after 30 seconds.
Your mission: Draw a flow where:
1. Admin clicks "Send".
2. API responds "OK" in 10ms.
3. A Queue + Workers system handles sending in the background.
For the Curious (Bonus)
Solution: You provide a "Callback" URL (Webhook). When the Worker is done, it calls this URL to tell you "It's ready!". It's like telling the delivery driver: "Ring my bell when you arrive".
"User Registered" → Queue → Worker "Welcome Email" + Worker "Analytics" + Worker "CRM".
This is the basis of modern "Reactive" and Serverless (AWS Lambda) architectures.