- Problem of retrieving data from multiple services in a microservice architecture.
- Uses an API composer to retrieve data from multiple services and combine the results.
- An API composer can be a client or a service.
- A service can a API gateway or a standalone service.
- Decide who plays the role of the API composer
Decision Situation Not a client - Clients that are outside of the firewall and access services via a slower network.
A standalone service - The data combination logic is complex.
- The query operation is also used internally by other services.
API gateway - The data combination logic is simple.
- The query operation is for external calls.
- Simple and useful.
- Increased overhead (larger network latency and buring more system resources).
- Risk of reduced availability (One service may be unavailable during the query operation).
- A query operation may return inconsistent data.
Topic | Consideration | Possible Solution Options |
---|---|---|
Scalability | The data needs to be combined can be large. | |
Complexity | The data combination logic can be complex. |
|
Availability | One service may be unavailable during a query operation. |
|
Performance | The latency can be increased by calling multiple services. |
|
- A client needs to communicate with multiple backend services to perform an operation.
- The client may use networks with significant latency
- Book: Chris R.(2018). Chapter 7 Implementing queries in a microservice architecture, Microservices Patterns (pp. 220-252). Manning Publications
- Book: Sam N.(2015). CHAPTER 4 Integration, Building Microservices (pp. 39-78). O'Reilly Media
- Web Article: Pattern: API Composition | https://microservices.io/patterns/data/api-composition.html
- Web Article: Gateway Aggregation pattern | https://docs.microsoft.com/en-us/azure/architecture/patterns/gateway-aggregation