What is the API composition pattern?
Answer
The API composition pattern is used to query data that is spread across multiple microservices. An API composer (typically the API gateway or a dedicated aggregator service) makes parallel calls to multiple services and merges their results into a single response for the client. For example, displaying an order detail page might require fetching order data from the order service, customer info from the customer service, and shipping status from the shipping service — the composer retrieves all three and combines them. The limitation is that API composition only works well for simple aggregations; complex queries (like a filtered, sorted, paginated list spanning multiple services) require a separate CQRS read model or search index instead.
Previous
What is the difference between Kafka and RabbitMQ for microservices messaging?
Next
What is the Transactional Outbox pattern?
More Microservices Architecture Questions
View all →- Intermediate What is event-driven architecture and how does it apply to microservices?
- Intermediate What is the Saga pattern in microservices?
- Intermediate What is CQRS (Command Query Responsibility Segregation)?
- Intermediate What is event sourcing in microservices?
- Intermediate What is the Circuit Breaker pattern?