Terminology (6)Terms used in this lesson
Term on the front, definition on the back. Paste with tabs between fields and a new line between cards, or import the download in Anki as Basic.
- Fan-out
- One request calling many backends in parallel and combining their answers.
- Tail latency
- The slow end of a latency distribution, such as the slowest 1% of calls.
- Per-call objective
- How often one backend call must meet a latency threshold, for example 99.5% within 300 ms.
- Required call
- A call the request waits for before it can answer.
- Optional call
- A call whose result is shown if it arrives in time and skipped otherwise; it never delays the answer.
- Hedged request
- Sending a second copy of a slow call to another replica and using whichever answers first.
Why this matters
Search, feeds, dashboards and microservice pages all fan out: one request, many backend calls. Each backend team watches its own percentile, and every one can be healthy while users wait. Promising anything about the whole request means converting between per-call and per-request numbers, in both directions.
This lesson assumes independent probabilities and percentiles from earlier lessons.
What fan-out does to latency
Fan-out sends one request to several backends. If the response needs every result, its completion time follows the slowest required call, plus dispatch and merge overhead. Tail latency describes the less frequent slow responses beyond a chosen threshold.
The chance of meeting that threshold depends on the calls being fast together. Under the lesson’s independent-call model, their probabilities multiply. Which calls block the response therefore matters as much as each call’s own percentile; the worked model sets overhead aside explicitly.
01The slowest call decides
The slowest call decides
A log search queries 40 partitions and answers when the last one does. Each partition meets 300 ms 99.5% of the time, so every dashboard is green. Under an independent-call model, nearly one search in five still misses 300 ms. The slow 0.5% of each partition is common once a request waits for forty of them.
The search starts all partition calls together and waits for the slowest. Ignoring dispatch and merge overhead, Tsearch=max(T₁,…,Tₙ), so P(Tsearch≤300 ms)=P(all Tᵢ≤300 ms)=pⁿ under independence. Predict the three lines this program prints.
const p = 0.995; // one partition meets 300 ms this often
console.log((p ** 40).toFixed(6)); // a search over 40 partitions
let calls = 0;
while (p ** (calls + 1) >= 0.9) calls++;
console.log(calls); // most partitions for 90% of searches
console.log((0.99 ** (1 / 3)).toFixed(6)); // per read, for 99% of pages with 3 required reads
| Per call | 10 calls | 40 calls | 100 calls |
|---|---|---|---|
| 99% | 0.904 | 0.669 | 0.366 |
| 99.5% | 0.951 | 0.818 | 0.606 |
| 99.9% | 0.990 | 0.961 | 0.905 |
02How far fan-out can grow
How far fan-out can grow
To keep 90% of searches within 300 ms at 99.5% per partition, add partitions while 0.995ⁿ stays at or above 0.9: 0.995²¹ = 0.9000 and 0.995²² = 0.8955, so 21 partitions is the limit. The quick estimate (1 − 0.9) ÷ (1 − 0.995) = 20 is close, but checking successive computed products retains the declared boundary instead of flooring an approximate logarithm.
p ** n and target ** (1 / k) cover both directions. The lab supplies a fixed integer-power multiplication sequence for unrounded decision comparisons.
03Required and optional calls
Required and optional calls
The search page waits for matches, access permissions and index metadata, then streams a histogram and suggestions. Only the three awaited calls enter this completion-time model. If the team makes the histogram required, the page now waits for four calls, and its latency promise needs a stricter objective from every backend or a looser promise.
04Back a promise
Back a promise
06Size the search fan-out
Size the search fan-out
The search planner needs three answers from the same model: request success at a fixed fan-out, the last fan-out that still reaches its target, and an equal per-call objective for the actual blocking set. Hard must report the root while checking the current required-call product; counting streamed panels can make a feasible request look short.
A fanned-out log search
Whole-search latency, the fan-out limit, then the per-call objective.
In the frontend Required and streamed data in Next.js and Svelte Optional
The page awaits its required data together and lets optional panels stream in, so the histogram is outside the awaited data set. Optional requests can still contend for shared resources; streaming removes a direct await, not all possible effects on latency. The application supplies the data functions and display components shown here.
import { Suspense } from "react";
// Required data is awaited together; optional panels stream in and never hold the page.
export default async function SearchPage({
params
}: {
params: Promise<{ query: string }>;
}) {
const { query } = await params;
const [matches, access, index] = await Promise.all([
getMatches(query),
getAccess(query),
getIndex(query)
]);
return (
<main>
<Results matches={matches} access={access} index={index} />
<Suspense fallback={<p>Loading histogram…</p>}>
<HistogramPanel query={query} />
</Suspense>
</main>
);
}
async function HistogramPanel({ query }: { query: string }) {
const histogram = await getHistogram(query);
return <Histogram data={histogram} />;
}
Check this idea later
Sources
Values above were computed in Node 22 and run in Go 1.27, Rust 1.99 and Apple clang 17. The log search is a worked model.
Sign in to keep your read marks on every device. Sign in
Was this helpful?