download

Each call's p95 is 200 ms. What is the request's p95?

System design~12 minReviewed 1 Nov 2026Free · No sign-in

Question

Before calling the model, a support bot makes two calls in a row: a vector search and a user-profile lookup. The dashboard shows a p95 of 200 ms for each call. A teammate says the two calls together have a p95 of 400 ms.

You have the timings of 20 requests from two weeks. Each call takes 200 ms, except once per call each week, when it takes 1,000 ms.

  • Week A: both slow calls hit request 1.
  • Week B: the search is slow on request 1, the profile lookup on request 2.

What is the p95 of the two calls together in each week? And if the calls ran in parallel?

Show hints (3)
  1. "RANK 19 OF 20"

    With nearest rank, the p95 of 20 values is the 19th smallest. Only the single largest value is above it.

  2. "ADD PER REQUEST"

    Add the two times for each request, then sort the 20 totals. How many slow requests does each week have?

  3. "PARALLEL WAITS"

    In parallel, a request waits for the slower of its two calls. Take the max for each request, then the p95.

Show checked explanation

You can't get it from the two p95s: percentiles don't add. Add the times per request, then take the p95 of the totals: 400 ms in week A and 1,200 ms in week B, with the same dashboards. In parallel, take the slower call per request: 200 ms and 1,000 ms.

"SOLUTION · PYTHON"
import math


def p95(values):  # nearest rank: sort, take value number ceil(0.95 * n)
    ordered = sorted(values)
    return ordered[math.ceil(len(ordered) * 95 / 100) - 1]


fast, slow = 200, 1000
search = [slow] + [fast] * 19  # slow on request 1
weeks = {"A": [slow] + [fast] * 19,  # profile slow on request 1 too
         "B": [fast, slow] + [fast] * 18}  # profile slow on request 2
for week, profile in weeks.items():
    in_a_row = [s + p for s, p in zip(search, profile)]
    in_parallel = [max(s, p) for s, p in zip(search, profile)]
    print(f"week {week}: calls {p95(search)} and {p95(profile)} ms, "
          f"in a row {p95(in_a_row)} ms, in parallel {p95(in_parallel)} ms")
"OUTPUT"
week A: calls 200 and 200 ms, in a row 400 ms, in parallel 200 ms
week B: calls 200 and 200 ms, in a row 1200 ms, in parallel 1000 ms

Code run on CPython 3.12 against the timings above. Checked by an editor other than the author.

Walkthrough

A percentile forgets which request was slow. To get the p95 of the whole path, you need each request's own timings.

weektotals in a rowp95 in a rowtotals in parallelp95 in parallel
A19 × 400, 1 × 2,000400 ms19 × 200, 1 × 1,000200 ms
B18 × 400, 2 × 1,2001,200 ms18 × 200, 2 × 1,0001,000 ms

In week A both slow calls hit one request. That request is the 20th value, above rank 19. In week B the slow calls hit two requests. Now the 19th value is a slow request, so the p95 jumps to 1,200 ms. Yet each call's own p95 is 200 ms in both weeks.

So the sum of the p95s, 400 ms, is not a rule. It matches week A and is far too low for week B. With parallel calls it is too high: week A's real p95 is 200 ms. At another percentile the order can even flip. The p99 is 2,000 ms in week A and 1,200 ms in week B.

In practice:

  • Record the time of the whole request, end to end, and compute its percentiles directly.
  • Use tracing with one request id across services to see which call made a request slow.

Common mistakes

  • Adding the per-call p95s and calling it the request's p95. Here that gives 400 ms, but week B's real p95 is 1,200 ms.
  • Averaging the p95s of several servers. The p95 of all requests is not the mean of the servers' p95s. Merge the raw timings or histograms first.
  • Trusting a p99 from 20 requests. With nearest rank it is simply the slowest request. You need far more requests to set goals for the tail.

Follow-up questions

  • "Search fans out to 100 shards and waits for all of them. Each shard is slow on 1% of calls. How often is a request slow?" If each shard is slow at random, unrelated to the others, a request is fast only when all 100 are fast: 0.99 to the power 100 ≈ 0.37. So about 63% of requests are slow. Dean and Barroso give this example in "The Tail at Scale" (2013).
  • "How do you cut that tail without making each shard faster?" Send a hedged request: if a shard hasn't answered within its usual p95 time, send the same request to a replica, use the first answer and cancel the other. Dean and Barroso report that this adds only about 5% load. Or answer with the shards that replied in time.

What a strong answer covers

Says percentiles don't add and computes the p95 from per-request totals: 400 ms or 1,200 ms with the same per-call p95s. Uses the max for parallel calls. Knows fan-out makes rare slowness common and names hedged requests.

Open in interactive practice deck →

Original OfferVibe question. Topic idea from System Design with AI Interview Guide (Rohit Bhardwaj, 2026); text, examples and code are our own.
© 2026 OfferVibe · Text CC BY-NC-SA 4.0 · code MITFree to share and adapt with credit, not for commercial use. Code samples are free for any use.