Try
↑ ↓ move↵ openesc close

Interview prep / Distributed tracing

Junior · Distributed tracing · System design interview question

A service handles 10,000 requests a second and each request produces about 20 spans. Why not store every span?

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

A strong answer

Do the volume first. 10,000 requests times 20 spans is 200,000 spans a second. If a span is about 500 bytes once encoded, that is 100 MB a second, or roughly 8.6 TB a day, before indexing or replication. Most of it describes healthy, fast requests nobody will open.

There is also a cost on the request path. Creating spans, serialising them and sending them takes CPU and network from the service itself, and at this scale the overhead is measurable.

Sampling keeps a fraction. Keeping 1 percent cuts the example to about 86 GB a day. Dapper started with a uniform rate of 1 in 1024 and found it still produced enough data to find problems, because services that matter have so many requests that even a small fraction contains many examples of any common behaviour.

The price is that rare events can be missed. A problem affecting one request in a million will usually not appear in a 1 percent sample. That is why teams add rules that always keep errors or very slow traces, and why rates should come from metrics that count every request.

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