The interview problem

Practice prompt

Hundreds of workers report request latency. Produce a fleet p99 with bounded memory and explain why averaging worker p99 values is wrong.

Original practice, not a reported company interview. All scenarios and worked numbers are illustrative. Interview date: not applicable. Sources retrieved September 30, 2026.

1. Scope and assumptions

Assume nonnegative latencies, explicit time windows and a mergeable quantile sketch with documented rank-error behavior. This focuses on quantile aggregation rather than general metrics ingestion.

2. Worked approach

observations
  → window sketch + contribution ID
  → compatible deduplicated merge
  → percentile

Workers feed observations into per-window sketches and report counts, sketch configuration, window IDs and producer epochs. Aggregators merge compatible sketches and publish the count, estimated percentile and approximation parameters. Handle retries with contribution IDs or replaceable snapshots: merging the same contribution twice changes its weight.

Finalize windows after a stated lateness policy. Keep late revisions versioned rather than silently changing an old dashboard. Separate logical request latency from retry-attempt latency. A percentile is meaningful only after defining which observations and failures belong to the population.

3. Calculate the example

Worker A serves 990 requests at 10 ms, while worker B serves 10 requests at 1,000 ms. Using nearest-rank quantiles, fleet p99 is the 990th of 1,000 sorted values, or 10 ms; the unweighted mean of worker p99 values is 505 ms. Fleet p99.9 is 1,000 ms. A rank error of 0.5 percentage points around p99 spans ranks near 985 to 995 here, crossing the sharp jump; it is not a 0.5% latency-value error.

4. Failure cases and trade-offs

Merging incompatible sketch formats corrupts results. Replayed windows double-count observations. A clock jump assigns samples to the wrong window. Validate metadata, count totals and event-time rules, and preserve a small exact reference dataset for regression checks.

Histograms with fixed latency buckets give predictable value resolution but need bucket choices. Quantile sketches adapt to distributions but generally bound rank rather than value error. Exact storage supports audit queries at higher cost. Choose based on the decisions the percentile drives.

5. Validate the result

Compare sketches against exact sorted values on heavy-tailed and two-point data. Test unequal worker counts, duplicated contributions and late arrival. Report approximation uncertainty separately from statistical uncertainty about future traffic.

6. Interview follow-ups and self-review

Can a sketch subtract a deleted producer contribution? How would you revise a finalized window?

Reward weighted population reasoning, correct percentile arithmetic, merge idempotency and rank-versus-value distinction.

Sources and related practice

Technical reference: datasketches.apache.org — Mergeable quantile sketches and rank-error background; examples and protocol are original.

Exact publication/update date not established in this review. Retrieved September 30, 2026. This reference supports the named technical concept; the proposed workflow and examples are original, not a documented vendor implementation or interview report.

Continue with Design a metrics ingestion platform; Design tiered time-series retention and downsampling.

Continue your preparation

Choose a connected learning path or browse more System design questions. Read our editorial method and attribution policy.