Microservice Communication - Synchronous
Overview of Synchronous Communication
Section titled “Overview of Synchronous Communication”- Synchronous communication is the simplest and most common inter-service communication in microservices.
- One service exposes an HTTP endpoint (or similar), and another service makes a request to that endpoint.
- The calling service waits for the response before proceeding to other tasks.
- Endpoints may use JSON-based APIs, gRPC, or GraphQL, but the process remains fundamentally the same.
Benefits of Synchronous Communication
Section titled “Benefits of Synchronous Communication”- Immediate confirmation of operation completion is possible—success or failure can be instantly determined by the returned response or error code.
- The communication style is familiar to developers, resembling a traditional method call within a single process application.
Trade-offs and Drawbacks
Section titled “Trade-offs and Drawbacks”- Synchronous communication introduces runtime coupling; services must know where and how to reach each other at runtime.
- Every consuming service requires up-to-date knowledge of the service location and must assume the service is available and running.
- If the external service is down or unavailable, the calling service is directly impacted, necessitating resilient error handling to prevent cascading failures.
- Performance issues or increased latency in an external service will directly affect the calling service.
- Chaining multiple synchronous inter-service calls can cause latency to increase exponentially, raising the risk of cascading failures.
Guidance and Considerations
Section titled “Guidance and Considerations”- Over-reliance on synchronous calls should be avoided due to increased risk and complexity.
- Developers are encouraged to evaluate whether the call must be processed synchronously or if a delayed (asynchronous) response is sufficient.
Suggested Action Items
Section titled “Suggested Action Items”- Carefully evaluate all synchronous inter-service calls to determine if any can be made asynchronous to improve system resilience and reduce runtime coupling.