Scrivio Interview library
ScenarioIntermediate6 min read · updated 12 November 2026

A checkout endpoint calls five services synchronously and its p99 latency is three seconds; availability is lower than any single service. Explain why and how you would improve it.

Availability multiplies along a synchronous chain, so five services at 99.9 percent each give the checkout roughly 99.5 percent, lower than any one of them, and sequential calls add their latencies while the p99 is dominated by whichever call is slowest at that moment. We improve it by calling independent services in parallel with a timeout per call, moving non-essential steps such as emails and analytics to asynchronous events, and caching or replicating rarely changing data locally instead of calling for it.

Why this question is asked

A checkout that takes three seconds at the 99th percentile loses sales, and one that fails more often than any of the services it uses is a puzzle for many teams until they see the arithmetic. Interviewers like this scenario because it tests whether we understand how failure and latency compose in distributed systems, and whether we can turn that understanding into concrete changes. In this answer, we will work through why availability drops, why the tail latency is so high, and then apply three fixes: parallel calls with timeouts, asynchronous side effects, and local data.

1Why Availability Is Lower Than Any Single Service

For the checkout to succeed, every one of the five calls has to succeed. If each service is independently available 99.9 percent of the time, the probability that all five are up is 0.999 multiplied by itself five times, which is about 0.995. So the chain is available 99.5 percent of the time. Over a 30-day month, 99.9 percent allows about 43 minutes of failure; 99.5 percent allows about 3.6 hours.

The same logic applies to errors on individual requests. If each call fails 0.1 percent of the time, about 0.5 percent of checkouts fail. Every synchronous dependency we add makes the product of these numbers smaller, which is why long chains feel fragile even when each service looks healthy on its own dashboard.

Java
double each = 0.999;
double chain = Math.pow(each, 5); // 0.99501
double minutesPerMonth = 30 * 24 * 60; // 43200
double one = (1 - each) * minutesPerMonth; // about 43 minutes down for one service
double all = (1 - chain) * minutesPerMonth; // about 215 minutes, 3.6 hours, for the chain

2Why the p99 Reaches Three Seconds

The p99 latency is the time within which 99 percent of requests finish; the slowest 1 percent take longer. When the five calls run one after another, their times add up. A typical request may see 60 + 80 + 120 + 90 + 50 milliseconds, about 400 ms in total.

The tail behaves worse than the average. Each service has its own slow moments, such as a garbage collection pause, a cold cache or a slow database query. With five calls in a request, the chance that at least one of them hits its own slowest 1 percent is 1 minus 0.99 to the power of 5, about 4.9 percent. So the checkout's p99 is driven by the slowest call in each request, and if one service has a p99 of 2 seconds, that number dominates the checkout's p99 almost by itself. Add retries without timeouts, and three seconds is easy to reach.

Latency of one checkout, before the fixes
CallTypicalp99Needed to confirm?
Cart60 ms200 msYes
Pricing and tax80 ms300 msYes
Payment authorisation120 ms2,000 msYes
Loyalty points90 ms400 msNo, can follow later
Email receipt50 ms600 msNo, can follow later

3Fix 1: Call Independent Services in Parallel, With Timeouts

Look at which calls depend on each other's results. Pricing needs the cart contents, and payment needs the price, but loading the customer's saved addresses or checking a fraud score may not depend on either. Calls that do not depend on each other can run at the same time, so the total time is the slowest of them instead of the sum.

Every call also needs its own timeout, chosen from that service's normal p99 plus a margin, for example 300 ms for pricing. Without a timeout, one stuck service holds the checkout thread for as long as the client library's default allows, which can be tens of seconds. With a timeout, a slow call fails fast and the checkout can retry once on another instance, show a clear error or fall back to a default.

Java
var cart = CompletableFuture.supplyAsync(() -> carts.get(id), pool).orTimeout(250, MILLISECONDS);
var fraud = CompletableFuture.supplyAsync(() -> fraudScore.of(user), pool).orTimeout(300, MILLISECONDS);
CompletableFuture.allOf(cart, fraud).join(); // waits for the slower one, about 120 ms, not 60 + 120
Price p = pricing.total(cart.join()); // depends on the cart, so it runs after it

Note that orTimeout completes the future with a TimeoutException; the HTTP client underneath should also have a read timeout so the thread is not held after we stopped waiting.

4Fix 2: Move Non-Essential Steps to Events

The customer needs to know that payment succeeded and the order exists. They do not need to wait while we award loyalty points, send a receipt email or record analytics. Those steps can happen a second later without anyone noticing, so the checkout should publish an OrderPlaced event, written reliably with an outbox table in the same transaction as the order, and return.

This removes two of the five calls from the critical path entirely. They no longer add latency, and a loyalty service outage no longer fails checkouts; its consumer simply catches up when it recovers. The chain's availability rises from five factors to three, about 99.7 percent, before any other change.

Step throughCheckout after the changes
  1. Load cart and fraud score in paralleleach with its own timeout
  2. Price from local tax tabletax rules replicated, no remote call
  3. Authorise paymenttimeout, one retry with idempotency key
  4. Payment approved?
    YesSave order and outbox row in one transactionNoReturn a clear payment error
  5. Return confirmation to the customercritical path ends here
  6. Consumers handle OrderPlacedloyalty points, receipt email, analytics

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

5Fix 3: Keep Rarely Changing Data Locally

Some calls fetch data that hardly ever changes: tax rates per region, product names, shipping zones. Calling a service for them on every checkout spends latency and availability on information we could hold ourselves. A local cache with a sensible expiry, or a copy kept up to date from change events, answers in microseconds and keeps working when the source service is down.

The price is staleness. A tax rate change might take effect a few minutes late in the cached copy, so for each piece of data we decide what lag the business can accept. For a value that must be exact at the moment of purchase, such as the payment result, we keep the synchronous call.

6Follow-up questions

Would adding retries fix the availability problem?

Retries help with brief, random failures, but they also add latency and load. Retrying a slow service makes it slower, and retries at several levels multiply. We use at most one retry, only on idempotent operations or with an idempotency key, inside the overall time budget, and combine it with a circuit breaker so we stop calling a service that is clearly down.

How would you prove the improvement?

We measure checkout p50, p99 and error rate before and after, using tracing to see each call's share of the time. After the changes we expect the p99 to follow the slowest remaining critical call, roughly the payment authorisation, and the error rate to fall because fewer services sit on the critical path.

What if payment authorisation itself has a 2 second p99?

Then it deserves its own investigation, because it now dominates the checkout. Options include a tighter connection pool and timeout configuration, talking to the payment provider about their latency, or accepting the order and authorising asynchronously with a pending state, if the business is comfortable with that experience.

7Conclusion

In this answer, we saw that a synchronous chain multiplies availability, so five services at 99.9 percent give about 99.5 percent, and that sequential calls add latency while the p99 is dominated by the slowest call. We improved the checkout by calling independent services in parallel with a timeout each, moving loyalty, email and analytics to events so they leave the critical path, and keeping rarely changing data such as tax rates locally.

What to say in the interviewAbout 90 seconds aloud

Open with

The chain explains both numbers. For checkout to succeed, all five synchronous calls must succeed, so availabilities multiply: five services at 99.9 percent give about 99.5 percent, which is more than three hours of failure a month instead of forty minutes.

Then, if they want more

Latency adds up for calls made one after another, and the tail is worse than the average, because with five calls there is about a five percent chance that at least one of them is in its own slowest one percent.

So the checkout's p99 is driven by the slowest dependency, and missing timeouts or retries can push it to three seconds. To improve it, I would first look at which calls depend on each other and run the independent ones in parallel with CompletableFuture or similar, each with a timeout based on that service's p99, plus matching HTTP client timeouts.

Second, I would take non-essential steps like loyalty points, receipt emails and analytics off the critical path by publishing an OrderPlaced event through an outbox, so their outages no longer fail checkouts. Third, for data that rarely changes, like tax rates or product names, I would use a local cache or a replicated copy instead of a call.

Then I would measure p99 and error rate per call with tracing to confirm the gain.

About this answer

Last updated
12 November 2026
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 "A checkout endpoint calls five services synchronously and its p99 latency is three...": https://scrivio-interview-library.netlify.app/spring-boot/microservice-design/dcb4e2a65c/