Problem
Data owned by separate services cannot be joined with a database query. Clients needing a combined view would otherwise make many calls and stitch the data themselves.
Also known as: api-aggregation, query-composition
Answer a query spanning several services by calling each and joining the results in memory.
Data owned by separate services cannot be joined with a database query. Clients needing a combined view would otherwise make many calls and stitch the data themselves.
API composition is the simplest way to implement queries across service boundaries. A composer calls the services that own each piece of data and joins the answers itself. It trades storage complexity for runtime coupling.
Take an order details page needing the order, its customer and shipment status:
GET /order-details/42
composer
|-- orders.get(42) -> order
|-- customers.get(order.cid) -> customer (needs order first)
|-- shipping.byOrder(42) -> shipment (parallel with customer)
merge -> single response
Independent calls run in parallel, so latency approximates the slowest chain, not the sum. Each call has a timeout and a fallback: if shipping times out, return the order with shipment marked unavailable. Results of slow-changing data, such as customer profiles, can be cached briefly.
Low - no new storage
Medium - tuning timeouts and fallbacks
Low - easy to understand
One slow service stalls the whole response
Partial failure returns misleading incomplete data
Fan-out multiplies load on downstream services