Synchronous Communication
The Calling Service Waits for a Response
With synchronous communication, service A sends a request to service B and cannot finish the current operation until it receives a response or an error. This model is natural when the result is needed right now.
Client -> Service A -> Service B
waits... |
<-----------+
For example, an order service may request the current product price from a pricing service if it cannot form a response to the user without that value.
The Advantage Is a Simple Execution Flow
The code is easy to read: send a request, receive a response, continue the computation. An error can be tied directly to the current user operation, and the client gets the result within one request.
HttpRequest request = HttpRequest.newBuilder(priceUri)
.timeout(Duration.ofSeconds(2))
.GET()
.build();
HttpResponse<String> response = httpClient.send(
request,
HttpResponse.BodyHandlers.ofString()
);
The Cost Is Time Coupling
While B responds slowly, A also keeps its request open longer. If A calls several services sequentially, delays add up, and unavailability of one participant can break the entire chain.
That is why synchronous calls need bounded timeouts and clear error behavior. A remote service must not be waited on forever: a stuck call gradually consumes resources on the calling side.