Try
↑ ↓ move↵ openesc close

Interview prep / Distributed tracing

Mid · Distributed tracing · System design interview question

What is the critical path of a trace, and why is the slowest span not always the one to optimise?

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

A strong answer

The critical path is the chain of spans that determines the end-to-end latency. Follow the trace from the end. When a service calls others in parallel, the path goes through the child that finished last. When it calls them in sequence, the path goes through all of them. The time the path spends in each span's own work adds up to the request latency.

A span off the path can be as slow as you like without affecting the total, because something else is still running when it finishes. A call with the longest own time may be one of several parallel branches, with another branch still going. Making it faster changes nothing.

So rank work by time on the critical path, not by duration or self time alone. Expect the path to move after a fix, because the next-slowest branch becomes the critical one.

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