Communication Between Services

Lesson 10 of 10 · 16 min

x
100%

Choosing the Right Communication Style

No single protocol fits every interaction. Use synchronous REST or gRPC when the caller needs an immediate answer and the operation is short-lived — "Does this user exist?" or "What is the current stock level?" Use async messaging when the caller can fire-and-forget, when you need to absorb traffic spikes, or when multiple services should react to the same event. A typical production system combines both: synchronous calls for read-heavy, latency-sensitive paths; events and queues for writes, notifications, and workflows. Add an API Gateway at the edge, service discovery behind it, resilience patterns on every outbound call, and sagas for multi-step business operations. Start simple — direct REST between two services — and add complexity only when measurement proves you need it.

Key Takeaway

Sync for queries that need an answer now; async for side effects and workflows — combine both and add resilience at every boundary.