Scrivio Interview library
LeadershipPrincipal7 min read · updated 12 November 2026

Many pages in your product fan out to 10 to 30 services and combine futures in an aggregation layer that grows every year. What long-term alternatives would you consider, and how would you weigh their cost?

In-process fan-out with futures is flexible, but every new dependency adds latency risk and a new way to fail, and tail latency grows with the number of calls. The long-term alternatives are a backend-for-frontend or GraphQL layer, which centralises aggregation but becomes a shared component someone must own, and precomputed read models updated by events, which trade freshness and storage for fast, simple reads. I would decide page by page, based on freshness needs, traffic and team ownership, and measure tail latency before and after any change.

Background to this question

An aggregation layer that grows every year is a slow-moving problem: no single change breaks it, but each new dependency makes pages a little slower and a little more fragile, until an incident shows that one minor service can take down the home page. A senior engineer is expected to see this trend early and to choose a direction that teams can sustain. In this answer, we will see why fan-out gets worse as it grows, look at three architectural alternatives and what each costs, and then walk through how we would decide and how we would prove the change helped.

1Why Fan-Out Gets Worse as It Grows

When a page calls 20 services in parallel, its latency is the latency of the slowest call. That makes the page much more sensitive to slow responses than any single service is. Suppose each service answers within 100 ms 99 percent of the time and is slow 1 percent of the time. The chance that all 20 are fast is 0.99 to the power of 20, about 82 percent. So roughly 18 percent of page views hit at least one slow call, and with 30 services it is about 26 percent. A tail event for each service becomes a normal event for the page.

Failure works the same way. Each dependency is another thing that can time out, return errors, or change its contract. And the aggregation code itself grows: timeouts per call, fallbacks for optional parts, retries, context propagation, mapping between models. The question is not whether the current code works but whether it will still be understandable and fast with 40 dependencies.

Java
// p99 of the page versus number of dependencies, each slow 1% of the time
// P(at least one slow) = 1 - 0.99^n
// n = 5 -> 4.9%
// n = 10 -> 9.6%
// n = 20 -> 18.2%
// n = 30 -> 26.0%

Notice how quickly the numbers grow. This is why we measure page tail latency, not average latency, when judging any of the options.

2Option 1: Keep In-Process Fan-Out, but Tame It

The cheapest option is to keep fanning out from the service that renders the page and make that code disciplined. That means a deadline per request, per-call timeouts derived from it, optional sections with fallbacks, fail-fast handling for essential parts, and a small library so every page does this the same way. On Java 21 and later, plain blocking calls on virtual threads, or structured concurrency once it is final in our JDK, can replace much of the callback code.

This keeps flexibility: each page team adds the calls it needs. The cost is that every new dependency still adds latency risk, and the knowledge of how to call 30 services lives in many page services at once.

3Option 2: A Backend-for-Frontend or GraphQL Layer

A backend-for-frontend, or BFF, is a service built for one client type, such as the web app or the mobile app, that does the aggregation in one place. A GraphQL gateway is a more general form: clients ask for the fields they need and the gateway resolves each field from the right service.

This centralises the hard parts. Timeouts, caching, batching of calls and partial responses are solved once, by people who specialise in them. The cost is ownership. The layer becomes a shared component that every product change touches, so it needs a clear owning team, good tooling for contributors, and capacity planning, or it turns into a bottleneck where every team waits for one team's review. It also does not remove fan-out; it moves it, so the tail latency arithmetic still applies to every query that touches many services.

4Option 3: Precomputed Read Models Updated by Events

The more radical option is to stop calling services at read time. Each service publishes events when its data changes, for example to Kafka, and a read-model builder keeps a document per page or per user up to date, such as a product page document holding price, stock and review summary. The page then needs one fast read from a store like a key-value database.

This makes reads fast and simple: one lookup, independent of how many services contributed. The costs are real, though. Data is only as fresh as the last processed event, which might be seconds behind. We pay for storage of every precomputed document, and for rebuilding them when the format changes. And we need to handle events that arrive late, out of order or twice. It suits pages with heavy traffic and tolerance for a little staleness, like product pages, much better than pages that must be exact, like a checkout total.

Three directions for a growing aggregation layer
OptionGainsCosts
In-process fan-out, disciplinedflexible, no new infrastructuretail latency still grows with each call
BFF or GraphQL layeraggregation solved once, per clientshared bottleneck that needs an owner
Event-driven read modelsone fast read, few runtime dependenciesstaleness, storage, event-handling complexity
No option is free; each moves the cost somewhere else.

5How We Would Decide, Page by Page

A single answer for all pages is usually wrong. A senior approach is to classify pages by what they need. How fresh must the data be: is a few seconds of delay acceptable, or must stock and price be exact? How much traffic does the page get: a page served a thousand times per second justifies precomputing, a back-office report does not. Who owns the data and the page: if one team owns most of the inputs, they can maintain a read model; if ten teams contribute, a BFF with clear contribution rules may fit better.

Here is a concrete example. The product detail page gets heavy traffic, tolerates stale reviews, and needs exact price only at checkout, so we move it to an event-driven read model with a live price check at add-to-cart. The account settings page has low traffic and must be exact, so it stays as disciplined fan-out. The mobile home screen combines many teams' widgets, so a mobile BFF with per-widget timeouts and partial responses fits.

Step throughChoosing an approach for one page
  1. Is a few seconds of staleness acceptable?
    YesConsider a read modelNoKeep live calls
  2. Is traffic high enough to pay for precomputing?
    YesBuild the read modelNoFan out with deadlines
  3. Do many teams contribute to the page?
    YesPut it behind a BFF with clear ownershipNoOwner team fans out itself
  4. Measure p99 and error rate before and afterkeep the change only if the numbers improve

4 steps in order. Play them, or step through them one at a time.

6Measuring Before and After

Whatever we choose, we decide with numbers. Before changing anything, we record for each page the p50, p99 and p99.9 latency, the error rate, and the number of downstream calls per request. After the change, we compare the same numbers under similar traffic. A move to a read model should show p99 falling sharply and calls per request dropping to one or two.

We also measure the costs we accepted: event lag for read models, storage growth, and for a BFF the lead time for teams to ship changes through it. If that lead time doubles, the bottleneck we feared has arrived.

7Follow-up questions

Would moving from CompletableFuture to virtual threads solve the problem?

It would make the aggregation code much easier to read and debug, which matters, but it would not change the latency arithmetic. Twenty calls are still twenty chances for a slow response. Virtual threads improve the code; reducing fan-out or precomputing improves the page.

How do you stop a BFF becoming a bottleneck?

Give it a clear owning team, let product teams contribute through well-defined modules with their own tests and timeouts, and keep it thin: aggregation and shaping only, no business rules. Track contribution lead time as a health metric.

When is a read model a bad idea?

When the data must be exact at read time, such as balances or final prices, when traffic is low enough that live calls are cheap, or when the inputs change so often that maintaining the model costs more than calling the services.

8Conclusion

In this answer, we saw that in-process fan-out is flexible but its tail latency and failure modes grow with every dependency, as the 1 - 0.99^n arithmetic shows. A BFF or GraphQL layer solves aggregation once but needs an owner to avoid becoming a shared bottleneck, and event-driven read models give one fast read in exchange for staleness, storage and event-handling work. We decide per page from freshness needs, traffic and ownership, and we keep a change only if tail latency and error rates measurably improve.

What to say in the interviewAbout 90 seconds aloud

Open with

I would start by making the problem visible. With fan-out, the page is as slow as its slowest call, so if each service is slow one percent of the time, a page with 20 calls sees a slow call about 18 percent of the time, and every new dependency also adds a way to fail.

Then, if they want more

So I would measure p99 and calls per request for each page. Then I see three directions. One is to keep in-process fan-out but discipline it: deadlines, per-call timeouts, fallbacks for optional parts, ideally simpler code on virtual threads. It stays flexible, but the latency risk keeps growing.

Two is a backend-for-frontend or a GraphQL layer, which solves aggregation once per client, but it becomes a shared component that needs a clear owner, or every team ends up waiting on it. Three is precomputed read models updated by events, so the page needs one fast read; that costs freshness, storage and the complexity of handling events.

I would not pick one for everything. I would decide per page: high-traffic pages that tolerate a few seconds of staleness get read models, exact low-traffic pages keep disciplined fan-out, and pages built by many teams go behind a BFF. And I would compare tail latency and error rates before and after each change.

About this answer

Last updated
12 November 2026
Versions it names
Java 21
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Many pages in your product fan out to 10 to 30 services and combine futures in an...": https://scrivio-interview-library.netlify.app/java/completable-future/13281f8a65/