System design paper · 2010
Dapper
How Google followed one request through hundreds of services and recorded where its time went, cheaply enough to leave switched on everywhere.
You’ll learn to
- Read the ids, parent ids and timestamps that join the pieces of one request into a tree.
- Explain how Google followed requests through threads and network calls without asking application teams to change their code.
- Work out how much data a sampling rate such as 1 in 1,024 produces, and why a second round of sampling happens before storage.
- Compare today’s tracing tools, Zipkin, Jaeger, OpenTelemetry and W3C Trace Context, with Dapper’s design.
The idea in short
One click on a large website can start work in hundreds of different programs, written by different teams. When the page is slow, nobody can say which program is to blame. Dapper gives every request an identity number. Each program then writes down, for each piece of work it does, its own number, its parent’s number and when it started and finished.
Joined up afterwards, those notes form a tree that shows where the time went. Google kept this cheap in two ways. The code lives in a few shared libraries, so teams change nothing. And only about 1 request in 1,024 is recorded, which is still plenty: anything common enough to matter shows up thousands of times.
The problem
In 2010 Google published a report on Dapper, the system it used to find out where time goes when one request touches many services. The authors had run it in production for over two years.
Their main example is a web search. A front-end server receives the query. It may pass it to hundreds of query servers, each searching its own slice of the index. It may also ask other systems for adverts, spelling fixes, images, videos and news, then merge everything into one results page. Google called this “universal search”. Thousands of machines and many different services could work on a single query, and people notice delay.
An engineer who only sees the overall response time knows something is slow but not which service to blame. The authors give three reasons.
- Services keep changing. New ones are added and old ones altered from week to week, so the engineer may not even know which services a request uses.
- Nobody knows everything. Each service is built and run by a different team, and no engineer is an expert in all of them.
- Services are shared. A machine or a storage system such as Bigtable, Google’s distributed table store (guide), may serve many clients at once, so a request can be slow because of someone else’s traffic.
The cure is to record what every service did for one request and join the records. That joined record is called a . Building the tool raised two needs. It must run everywhere, because even small unmonitored parts make it much less useful. And it must run all the time, because strange behaviour is often impossible to reproduce later.
Those needs became three goals:
- Low overhead. Tracing must slow services down by a negligible amount. In some highly tuned services, even small costs are noticed and the owners would switch the tool off.
- Transparency to applications. Programmers should not have to know the tracing system exists. A tool that depends on every developer adding code breaks whenever someone forgets or makes a mistake.
- Scalability. It must cope with Google’s size for at least the next few years.
So the question the paper answers is: how can a company record where one request’s time went, across thousands of machines and many teams, so cheaply that nobody turns it off and so automatically that no team has to do any work?