What is the API Composition pattern, and what are its limitations compared to CQRS for cross-service queries?
Last updated
API Composition: a composer (gateway or service) calls each owning service, ideally in parallel, and joins the results in memory at request time.
Limitations: inefficient in-memory joins, no clean cross-service filtering, sorting, or pagination, and latency and failure risk that grow with each call (plus N+1 fan-out).
CQRS serves heavy queries from an event-updated materialized read model, at the cost of an extra store and consistency lag. Use composition for simple, low-volume joins.
- https://microservices.io/microservices/news/2017/08/01/data-patterns-presentation.html
- https://helpezee.wordpress.com/tag/api-composition/
- https://progressivecoder.beehiiv.com/p/microservices-patterns
- https://stackoverflow.com/questions/62550972/designing-the-query-layer-in-cqrs
- https://stackoverflow.com/questions/55791575/microservices-joins
- https://www.geeksforgeeks.org/system-design/api-composition-pattern-in-microservices/
- https://learncsdesigns.medium.com/microservices-data-design-patterns-69a31d5aa4a0