API Composition Lab (Interactive)
Fan out to four backend services in parallel or sequence and choose fail-closed versus partial fallback renders. The aggregator pattern composes a dashboard from order, user, payment, and recommendation services. Parallel gather takes max(latency) plus merge cost instead of the sum.
Scatter-Gather API Composition
The BFF fans out to four private-database services concurrently. Tune each latency, break a dependency, and watch partial degradation.
Order Service
CRITICAL (fail-closed)→ fulfilled in 15 ms
User Profile Service
CRITICAL (fail-closed)→ fulfilled in 22 ms
Payment Service
CRITICAL (fail-closed)→ fulfilled in 38 ms
Recommendation Service
NON-CRITICAL (fail-open)→ fallback: empty list []
Non-critical section(s) served from fallback defaults; the healthy sections still render — the user never sees a 500 screen.
How It Works Under the Hood
Screen-level data usually lives across multiple bounded contexts, so an API composition service issues parallel scatter-gather calls and merges the results into one response. Parallelizing collapses latency from the sum of dependencies to the maximum plus a few milliseconds of merge work. Criticality decides failure behavior: order and payment sections fail closed with a 503 because showing partial financial state is dangerous, while recommendations fail open to defaults. The aggregator keeps a per-call timeout budget so one slow dependency cannot pin its threads indefinitely.
Core Architectural Principles
- Sequential composition sums all dependency latencies; parallel scatter-gather executes max(T_i) plus merge.
- Critical sections (payment, order) fail closed with 503; non-critical sections fall back to defaults.
- The aggregator timeout caps the render: anything slower than the budget is treated as failed.
For dashboard or feed designs, propose an explicit composition layer and say why: clients should not fan out to twenty services on mobile networks. Quantify the win: parallel gather turns a 165 ms sequential render into roughly max latency plus merge. Then handle the hard part — per-section criticality, partial failure rendering, and its own timeout budget.
One clean client-facing call versus an extra hop, a new SPOF, and careful per-section fallback policy.