Try
↑ ↓ move↵ openesc close

Interview prep / Distributed tracing

Senior · Distributed tracing · System design interview question

Design a tracing pipeline for a large service so that slow and failed requests are always kept, overhead is low, and cost is bounded.

Sketch your own answer first, then compare it with the one below.

A strong answer

Split the problem into recording, collection and storage, and put the expensive decision where the information is.

Recording: instrument shared libraries so application code is untouched, and make the cost of an unsampled span very small. Dapper reports that unsampled annotations are nearly free, which is what lets tracing stay on everywhere. Propagate the sampling flag in the trace context.

Collection: send spans to a tier of collectors, routed by trace identifier so all spans of one trace land on the same one. There, hold each trace in a buffer until it finishes or a timeout passes, then apply tail rules: keep traces over a latency threshold, traces with errors, and a small random baseline. Bound the buffer in memory and decide what to do when it fills, for example fall back to head-sampled decisions.

Storage and cost: apply a second round of sampling or a rate target per service so a noisy service cannot use the whole budget, and keep counters of everything seen so rates can be recovered from metrics. Plan for the case where a bad incident makes most traces slow, since a tail sampler then stores most of them.

Then list how it fails: dropped spans, clock skew, collectors restarting with traces in flight. Measure the pipeline itself, for example by checking that the share of slow traces it stores matches what metrics say was slow.

Sources

Learn it by running it

The distributed tracing lesson explains the mechanism behind this question, and its lab lets you change the parameters and watch the effect.

Your progress is saved in this browser. Sign in to keep it on every device. Privacy · Terms