API composition
Definition
API composition is a query pattern where a composer, such as a BFF or gateway, invokes the services that own the needed data and joins their results in memory.
In practice
With data spread across services, a screen that needs profile, orders and recommendations would otherwise make three round trips from the client. Composing near the services turns that into one client call and parallel internal calls, cutting latency on high-latency networks.
The composed response is only as fast as the slowest call and, without fallbacks, only as available as the product of its dependencies. Use timeouts and serve partial results when an optional part fails. Large in-memory joins across services are slow; a precomputed read model may be better.
Example
The composer calls profile (20 ms), orders (45 ms) and recommendations (120 ms) in parallel; with a 150 ms timeout on recommendations, the page returns in about 125 ms or omits that section.