Try
↑ ↓ move↵ openesc close
In this lesson · topic 4 of 7
  1. 1. Why one request needs a trace
  2. 2. Spans, context and the critical path
  3. 3. Reshape a service tree, then sample it
  4. 4. When one slow call in a hundred reaches most requests
  5. 5. Traces that cross a queue
  6. 6. What a tail sampler costs to run
  7. 7. Off-path spans, 100 backends, keeping slow traces

Topic 4

When one slow call in a hundred reaches most requests

6 min read

These figures come from a seeded run of the tracing simulator, and tests pin them. Hover a measured value for the exact setup.

Many calls make rare slowness common

Suppose one call in a hundred takes its slow path. That sounds rare. Now a request makes several calls in parallel and cannot finish until they all do. If the calls are independent, the chance that none is slow is 0.99 raised to the number of calls, so the chance that at least one is slow is one minus that.

The lab draws independent calls and counts. With 10 parallel calls, 10%measured of requests met a slow one, against 10%measured from the formula. With 100 calls, 64%measured met one, against 63%measured. A single call met a slow one 1.3%measured of the time.

This is the central point of the Tail at Scale paper. Dean and Barroso argue that when requests fan out, the tail of each part decides the typical experience of the whole. A service whose components are each rarely slow can still be slow for most of its users.

In the call tree used for the figures on this page, 12measured calls sit below the gateway, and 11.8%measured of requests had at least one slow call, against 11.4%measured from the formula. In a wider tree with 84measured calls, 58%measured did.

The slowest span is not always the one to fix

In the default tree, calls alternate between parallel and sequential. In 26%measured of traces the call with the longest own time was off the critical path. Speeding it up would not have made the request faster, because another branch was still running when it finished.

With every call made in sequence, the same measurement says 100%measured of traces have the slowest call on the path, as they must: if nothing runs in parallel, every call is on it. This is the test for whether your tools are helping. A view that ranks spans by duration, with no critical path, will often send you to the wrong place.

Head sampling misses what you came for

With a head sampler that keeps ten percent, the lab stored 11%measured of all traces, and of the slow traces it kept 10%measured. Only 8%measured of the traces in its store were slow, almost the same as the 9%measured of traffic that was. The store is a fair picture of the traffic, and a poor picture of the problem.

A tail sampler that keeps every slow trace plus two percent of the rest stored 10%measured of traces, kept 100%measured of the slow ones, and 81%measured of what it held was slow. For about the same storage, it keeps the traces you would have gone looking for.

The cost shows up elsewhere. A tail sampler must hold every span of every trace until it ends, and all the spans of one trace must be sent to the same collector, or the decision is made on a partial picture. Its storage also grows with the share of traces that are slow. In the wider tree, a tail sampler with the same rule stored 24%measured of all traces, because so many requests had at least one slow call.

What independent calls leave out

The calls here are independent. In real systems a shared disk or a bad deploy makes calls slow in clusters. Clustered slowness hits fewer requests than the formula predicts, and hits those requests harder. Independence is the simplest case, not the typical one. The lab also never loses a span. In practice context gets dropped at queues, thread pools and third-party boundaries, clocks on different hosts disagree by milliseconds, and instrumentation itself adds latency, which is why Dapper’s authors spent so much effort on keeping its overhead low.

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