When to Use Async vs Sync
You'll learn a practical decision framework for choosing between synchronous APIs and asynchronous messaging in your system designs.
The Core Decision
When designing communication between services, you face a fundamental choice: should Service A wait for Service B's response (synchronous), or fire off a message and move on (asynchronous)? The right answer depends on specific requirements.
Decision Framework
Choose Synchronous Communication When:
- Immediate response required: The client needs data right now (e.g., fetching a user profile to display)
- Interactive workflows: User is waiting for confirmation (e.g., login verification)
- Simple request-response: The operation is fast and unlikely to fail
- Strong consistency needed immediately: You must know the outcome before proceeding
Choose Asynchronous Messaging When:
- Long-running operations: Tasks take seconds or minutes (e.g., video transcoding)
- High traffic variability: Need load smoothing to handle spikes
- Temporal decoupling: Services don't need to be available simultaneously
- Retry complexity: Operations frequently fail and need multiple attempts
- Fan-out scenarios: One event triggers multiple downstream actions
- Order processing acceptable later: Eventual consistency meets your needs
Real-World Example
User uploads a profile photo:
- Sync: Validate file format immediately, return success/error
- Async: Queue thumbnail generation, image optimization, backup to storage — user doesn't wait
Key Takeaway: Use sync when you need immediate answers and simple flows; use async when you need resilience, decoupling, or can tolerate delayed processing. Many systems use both patterns for different operations.