Try
↑ ↓ move↵ openesc close

Distributed tracing lab

A request fans out across services with sequential and parallel calls. Read the span waterfall and its critical path, measure the tail at scale against the formula, and compare head and tail sampling.

13 spans per request (12 calls below the gateway)typical 68.6 msslow trace: over 137 ms

p50
75.7 ms
p95
181 ms
p99
258 ms
slow traces
9%
slowest call on path
74%

One trace, drawn as a waterfall

Which trace to draw
0.0 ms38.7 ms77.4 ms116 ms155 msgateway155 mscatalog68.4 msindex22.1 mscache13.9 msdb22.6 mspricing47.3 msindex11.7 mscache7.9 msdb13.8 mssearch151 msindex14.4 mscache19.9 msdb111 msslowest, on path

Filled bars are time spent on the critical path. Outlined bars finish while something else is still running. A red outline marks a call that took its slow path.

The filled parts add up to 155 ms, which is the end-to-end latency of 155 ms. The slowest call by its own time is db (111 ms), and it is on the critical path.

The tail at scale

Chance a request waits on at least one slow call
Chance a request waits on at least one slow call. Text version available below the chart.0%25%50%75%100%N=1N=10N=100parallel calls per request, Nshare of requests
Share of requests with at least one slow call, measured and from the formula
N125102050100
Measured1%2%5%11%19%39%64%
Formula1%2%5%10%18%39%63%

Measured over 600 requests for each N. A request is slow here if at least one of its N parallel calls took the slow path, which one call in 100 does. In the call tree above, 11.7% of requests had at least one slow call, and 1 - (1 - p)12 predicts 11.4%.

What each sampler keeps

Head sampling

Decides at the first span, before the outcome is known. Keeps 10% of traces at random.

stored
134 of 1200
slow traces kept
8%
kept that are slow
6%

Tail sampling

Decides once the trace is complete. Keeps every slow trace and 2% of the rest.

stored
130 of 1200
slow traces kept
100%
kept that are slow
82%

What to try

Each one sets up a starting point. Then make the change it describes.

  1. Find the critical path

    Pick "Latest trace where the slowest call is off the critical path" above the waterfall. Find the filled bars and the call marked as the slowest.

    Look for. The slowest call by its own time finished before some other branch did, so shortening it would not make the request faster. The filled bars are the only ones that set the end-to-end time.

  2. Make every call sequential

    Set the call pattern to all sequential and read "slowest call on path".

    Look for. With no parallelism every span is on the critical path, the trace is one long chain, and the slowest call is always on it. Parallel calls are what separate the slowest span from the critical one.

  3. Fan out wider

    Set depth 3 and fan-out 4, then look at the tail-at-scale table and the share of slow traces.

    Look for. Each call is rarely slow, but a request that makes dozens of calls is very likely to include at least one that is. The measured share follows 1 minus (1 minus p) to the power of the number of calls.

  4. Turn up the slow share

    Raise slow calls to 5 percent and watch the measured line on the tail-at-scale chart.

    Look for. The measured points stay on the formula curve and the curve climbs faster. At 5 percent even a handful of parallel calls makes a slow request common.

  5. Head against tail

    Lower the head sampling rate to 5 percent and compare how many slow traces each sampler kept.

    Look for. The head sampler decides before it knows the outcome, so it keeps about its rate of the slow traces and misses the rest. The tail sampler decides after the trace is complete and keeps all of them, at the cost of buffering every trace until then.

New to the idea? Read the lesson first. Every number here comes from a seeded simulator, so the same seed gives the same run.

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