The interview problem
Design a multi-tenant distributed tracing service receiving 100,000 new traces per second, averaging 20 spans per trace and 500 encoded bytes per span. Retain errors and slow traces plus a probabilistic baseline. Support lookup by trace ID and searches by service and time. Explain tail-sampling memory, late spans, failures and what the retained traces can tell us about production traffic.
Original system-design practice, not a reported company interview. Workload and capacity assumptions are hypothetical. OpenTelemetry references retrieved September 27, 2026; interview date not applicable.
1. Define the collection contract
A trace contains related spans connected through propagated context. Its ID is a correlation key, not an authorization credential. Scope ingestion and queries by an authenticated tenant, and never trust a caller-supplied trace ID to grant access.
Clarify whether ingestion is best effort or acknowledges durable acceptance. The proposed service uses bounded SDK queues and a durable collector-side intake log for admitted spans. It cannot recover spans never exported by an application. Capacity rejection, SDK drops and retention decisions must be observable rather than hidden behind an “all errors captured” promise.
Telemetry should not indefinitely block customer requests. Define retry limits, queue bounds and shedding priorities. Separate the application's request counters and latency metrics from the trace pipeline so a tracing outage does not erase the only evidence of application health.
2. Route related spans to one decision owner
instrumented services and bounded SDK exporters
↓
regional authenticated collectors
validation, redaction and tenant admission
↓
durable partitioned intake log
↓
trace-affinity owners and tail buffers
↓
keep/drop decision + durable selected-span export
↓
trace blobs + bounded searchable index
↓
authorized trace lookup and diagnostic searchPartition using tenant and trace ID so all spans for a trace reach one sampling owner. Round-robin span routing can split the evidence across several decisions. OpenTelemetry's tail-sampling processor specifically requires trace affinity; the surrounding durable log in this design is an additional architectural choice, not a claim that its in-memory processor is durable by itself.
Use stable logical partitions and versioned ownership. Rescaling requires draining old owners or transferring buffered state and decision history. Changing a hash ring without a handoff can send early and late spans to different owners. Fence stale owners from producing conflicting decisions.
Deduplicate retries by tenant, trace ID and span ID. Identical retries should not add duplicate spans; conflicting payloads for the same identity require a documented policy and diagnostic signal. Preserve parent relationships even when wall clocks disagree. A root span ending does not prove that every asynchronous child or delayed exporter has arrived.
3. Size the unsampled path first
span arrival rate = 100,000 × 20 = 2,000,000 spans/second encoded ingress = 2,000,000 × 500 = 1 GB/second daily ingress = 1 GB × 86,400 = 86.4 TB/day
These are decimal units before compression, replicas and index overhead. Tail sampling reduces downstream retention, but the sampler must first receive the eligible input. Keeping 10% of traces gives 8.64 TB/day only if retained and discarded traces have equal average byte sizes. Error traces with more spans can consume a larger fraction of storage.
For a simple sizing scenario, suppose all 20 spans arrive together when a trace is first observed and remain buffered for 30 seconds:
active traces = 100,000 × 30 = 3,000,000 buffered spans = 3,000,000 × 20 = 60,000,000 encoded payload = 60,000,000 × 500 = 30 GB resident payload at assumed 3× expansion = 90 GB
Add maps, decisions, queues, allocator overhead and operating headroom. Real span arrival patterns and trace-size distributions change the result. The 90 GB figure is an assumption-driven estimate, not a memory bound. A twofold traffic burst doubles this estimate; a 120-second wait raises it to 360 GB under the same assumptions.
Across 100 evenly loaded owners, the 30-second case averages 30,000 active traces per owner. Skew and giant traces still require byte and span limits per trace and tenant. A maximum trace count alone does not bound memory. A proposed decision-history cache retaining 120 seconds of 100,000 decisions per second has 12 million entries; at a hypothetical 32 bytes per entry that is 384 MB before data-structure overhead. Actual implementation size and eviction behavior need measurement.
4. Treat a tail decision as a deadline, not proof of completeness
Use explicit states: accumulating, decided keep or drop, decision retained, and expired. Set the initial processing deadline from the first admitted span. Decide using the evidence present at that deadline and record the policy version. There is generally no universal signal that every span of a distributed trace has arrived.
For a kept trace, late spans can attach while its decision remains available. For a dropped trace, a late error cannot reconstruct earlier discarded spans unless a separate raw-retention mechanism still holds them. After decision expiry, define whether a late fragment is discarded or processed as a visibly partial fragment. Do not display a fresh decision as proof that the full original trace was evaluated.
OpenTelemetry's documented behavior distinguishes late spans while a prior decision remains buffered from spans arriving after eviction. Without retained decision state, a late fragment may undergo a new decision; a keep-decision cache can preserve the earlier result longer. Verify the deployed processor version and configuration rather than assuming an unlimited cache.
Choose the waiting window from observed arrival delays and diagnostic needs. A longer wait costs memory and delays visibility; it still cannot guarantee receipt of every span. Very long workflows may be represented as linked shorter traces, with the loss of a single all-encompassing sampling decision made explicit.
5. Make replay and acknowledgment semantics consistent
A collector returns durable acceptance only after the admitted batch is recorded under the promised replication policy. Report partial rejection precisely so clients retry only the appropriate data. Validation failures and tenant limits should not create unbounded retry loops.
The intake log allows replay after an owner failure, but replay alone is insufficient for consistent sampling. Persist the decision and its policy version, or provide a deterministic recovery process with equivalent state. Replay must also preserve the original decision deadline or recorded input boundary: restarting a fresh waiting window can admit different late spans and change the result. Keep the intake record until its required downstream state or explicit drop decision is durably accounted for. Export retries must be idempotent. A crash after storage succeeds but before checkpoint advancement should not create another logical span.
Bound replay retention and explain what happens if recovery falls behind it. An in-memory-only implementation offers a cheaper alternative with a weaker loss contract. Neither design should imply that downstream durability repairs application-side sampling, lost context propagation or SDK buffer drops.
6. Do not read production rates directly from selected traces
Consider 100,000 requests containing 1,000 errors and 99,000 healthy requests. Keep all error traces and a 10% probability sample of healthy traces. If the healthy sample contains 9,900 traces:
retained traces = 1,000 + 9,900 = 10,900 retained error fraction = 1,000 / 10,900 ≈ 9.174% production error fraction = 1,000 / 100,000 = 1%
The healthy sample count is illustrative; probability sampling does not guarantee exactly 9,900. The selected traces overrepresent errors by design. Naive error rates and latency percentiles from this population are not production estimates.
With known positive inclusion probabilities and no additional unaccounted loss, inverse-probability weighting gives estimated totals of 1,000/1 for errors and 9,900/0.1 for healthy requests. Their ratio is 1% in this example. Such weighted totals have appropriate design-based properties; a ratio of estimated totals is not generally an exactly unbiased finite-sample estimator. Unknown overload loss or incomplete error evidence breaks the simple calculation.
Use separately collected request metrics for operational SLIs and retained traces for diagnosis. If a 10% head sampler runs before the tail stage, only about 100 of the 1,000 error traces arrive in expectation. Keeping every error observed by the tail sampler does not retain every production error. Sampling decisions and propagated context must be coordinated; independent per-span sampling fragments traces.
7. Keep storage and search bounded
Store trace chunks keyed by tenant, trace ID and retention partition, with an index over approved attributes such as service, operation, time and observed status. Arbitrarily indexing every attribute invites cardinality and cost problems. Limit attribute counts and lengths, and redact secrets before durable retention.
Separate trace lookup from broader search. Search results should expose ingestion lag and evidence limitations. Missing parents, detected loss and late fragments can be flagged, but absence of such flags is not proof of completeness. A missing trace means it is unavailable or unretained, not that the request never happened.
Apply authorization at lookup and search, including cached responses. Coordinate blob and index expiry so stale index entries do not imply that expired evidence remains retrievable. Tenant-specific retention and deletion requirements also apply to intake logs and export queues, not only the final trace store.
8. Plan for the failures that occur during incidents
| Failure | Consequence | Response |
|---|---|---|
| Error storm | Keep-all-errors policy exceeds capacity | Apply explicit tenant budgets and report loss; preserve independent SLIs |
| Owner restart or rescale | Partial assembly or conflicting decisions | Replay, fence ownership and retain decision versions |
| Late error span | Earlier drop decision missed the error | Measure lateness and document partial-evidence behavior |
| Giant trace | One request consumes disproportionate memory | Enforce byte/span limits and mark truncation |
| Export destination outage | Backlog fills finite buffers | Bound retry and retention, expose queue age and shedding |
| Clock skew | Misleading cross-service timing | Use causal relationships and flag inconsistent timestamps |
Monitor admitted and rejected spans/bytes, SDK drops, trace evictions, decision latency, late-arrival age, export lag and cache eviction. Keep these pipeline-health metrics distinct from application error rates. Load-test skew, not just uniform traffic, and inject crashes around acknowledgment, decision persistence and export checkpoints.
9. Trade-offs and interview follow-ups
Head sampling is cheaper and reduces upstream volume, while tail sampling can prioritize outcomes learned later. Durable buffering improves recovery at storage and operational cost. Longer waits improve the chance of seeing late evidence but consume memory. Flexible search helps debugging but must stay within indexing budgets.
- Can you guarantee all errors are retained? Only within a carefully bounded collection contract; upstream drops, finite buffers and late evidence prevent an unconditional claim.
- A trace spans several regions. Choose a decision authority or an explicit cross-region aggregation strategy, accounting for transfer policy, delay and failure. Independent regional decisions can produce fragments.
- A tenant forges another tenant's trace ID. Authenticated tenant scope remains part of every routing and storage key.
- The sampling policy changes mid-trace. Associate the accumulation or decision with a documented policy version and preserve it through replay.
- A trace lasts for days. Reconsider the trace boundary and link shorter operations; a days-long in-memory wait is not the default solution.
Self-review rubric
A strong answer sizes the unsampled path, states buffer assumptions, preserves trace affinity and defines late-span and loss behavior. It aligns acknowledgments with durability, keeps replay idempotent and avoids treating selected traces as unbiased traffic metrics. An excellent answer handles rescaling, error storms, tenant isolation and the difference between observed evidence and a complete distributed execution.
Sources and attribution
- OpenTelemetry: Sampling — head/tail sampling and resource trade-offs; page last modified October 16, 2025.
- OpenTelemetry Collector: Tail sampling processor — trace affinity, in-memory state and late-span behavior; mutable main-branch documentation.
Retrieved September 27, 2026; original publication dates unstated. Validate implementation behavior against the deployed version. The prompt, architecture, capacity assumptions and sampling calculations are original practice material, with no company interview attribution.
Continue your preparation
Choose a connected learning path or browse more System design questions. Read our editorial method and attribution policy.