Why Services Communicate
In a monolith, modules call each other through in-process function calls — fast, simple, and transactional. In a distributed system, each service runs in its own process (often its own container or VM), so calling another service means crossing a network boundary. That boundary introduces latency, partial failures, and the need for explicit contracts.
Service communication falls into two broad families. Synchronous communication blocks the caller until the callee responds — like REST over HTTP or gRPC. Asynchronous communication sends a message and moves on — the receiver processes it later via a queue or event bus. Neither is universally better; the choice depends on whether the caller needs an immediate answer, whether failures should block the workflow, and how tightly coupled the services should be.
Check your understanding
What does a network boundary introduce that in-process calls do not?Show answerHide answer
Answer
Latency, partial failure, and the need for explicit contracts and timeouts.When is synchronous communication a fit?Show answerHide answer
Answer
When the caller needs an immediate answer and the operation is short-lived.When prefer async messaging?Show answerHide answer
Answer
When the caller can continue without waiting, spikes must be absorbed, or many consumers should react to one fact.