Try
↑ ↓ move↵ openesc close

Interview prep / Distributed tracing

Mid · Distributed tracing · System design interview question

In a trace, a parent span lasts 300 ms and has one child of 120 ms that starts 150 ms after the parent does. What explains the missing time, and how do you find out which explanation is right?

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

A strong answer

Lay out the numbers. The child runs from 150 ms to 270 ms, so the parent spent 150 ms before calling it and 30 ms after, 180 ms in all. That time belongs to the parent's own work, or to something the trace cannot see.

The usual suspects are uninstrumented work such as a database call or serialisation that has no span of its own, waiting for a thread or a connection from a pool, a garbage collection pause, and a lock. If the child runs on another host, clock differences matter too: a few milliseconds of skew moves its bar, though skew does not explain 150 ms.

To decide, look at the parent's self time and attach more evidence. Add spans around the suspicious calls and see whether the gap fills. Check metrics for pool wait and GC pauses on the parent's host at that time. Take a CPU profile or a thread dump from a slow instance, which shows where the time really goes. If the gap appears only in some traces, compare a slow one with a fast one and look for what differs, such as payload size or instance.

Do not guess a cause from the trace alone. The gap tells you where to look, not what is there.

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