Ch.82: DNS System Design: Build the Internet's Lookup Service
Outline
- 0:00 Find the address before connecting
- 0:52 The complete lookup service
- 1:31 What the caller may expect
- 2:17 The work behind a quick answer
- 3:05 Find the authority, then the address
- 3:53 Reuse doesn't restart the clock
- 4:43 Sometimes the answer is another name
- 5:25 Share a search already in progress
- 6:12 More workers change the cache
- 6:58 A silent server is not a missing name
- 7:53 Absence and failure need different memories
- 8:39 Which replies deserve trust?
- 10:43 An expired answer can still be useful
- 11:48 Different questions can still overwhelm us
- 12:35 A real availability-versus-trust choice
- 13:30 Trace the same service again
Transcript
0:00 DNS, the Domain Name System, finds network addresses for website names. Those addresses are the numbers devices use to reach servers. If that lookup fails, a working website can become unreachable by name. We'll design a recursive resolver, the service that does that search for your device, and follow how it answers quickly without trusting the wrong information. For example, our device is the caller, the one asking. It wants the address for the name on screen, which the resolver might know or need to find.
0:31 Knowing it and finding it fail differently. A saved result can grow old, while the servers we need to ask can stop responding. Both paths need limits. So we'll follow the address all the way back to the caller, keeping three questions separate: how recent it is, who supplied it, and what happens when lookup fails. Those questions lead to this map. The device reaches a serving location, one place we run the service. A worker is a running copy of our resolver. Its saved-answer path stays inside. Its other path asks servers responsible for DNS information, so we depend on systems we don't operate.
1:08 So the reply from one of those servers needs checking before we save it. Otherwise one wrong answer could be reused by many callers. Searches in progress let callers share the work. If another caller wants the same answer while we're searching, it can wait alongside the first one instead of starting us over. We'll return to this map once we've followed a request through it. Now follow the map's arriving query, a lookup request about a name. Our functional requirements say what callers can do. First, accept that request.
1:39 An A record gives a name's address in the four-number format shown. Second, follow a supported alias, where one name points to another. 3rd, give this caller an address, meaningful absence or honest lookup failure. 4th, let workers reuse answers under the same policy. We serve public internet data without private-network or location-specific answers. So if the resolver returns an address but the website still won't load, has our service succeeded? At its own job, yes. Finding an address doesn't prove that the website is healthy, so connection and application failures remain separate from our lookup result.
2:16 Now the non-functional requirements: how well that contract holds up. Our answer for this name needs to stay quick, age-bounded and trustworthy, even when a worker or outside server fails. Google's resolver documentation connects performance to a cache, a store of reusable answers that can avoid outside work. For this name, how much work actually leaves the service? Take an invented workload of 100,000 lookups per second. If 90% are cache hits, requests answered from saved records, 10,000 initially miss that cache.
2:49 That isn't automatically 10,000 network messages, called packets. One search may need several questions, while many callers can share a search already underway. So our capacity requirement includes bounded outside work, not just a quick cache reply. We'll link the sources in the description. Now follow that outside work through a cold lookup, without useful saved records. An authoritative server, or authority, holds records for a zone, the part of the naming tree it manages. The diagram starts at the root, then.com, then example.com's servers.
3:20 How can the root keep every website's address current? It doesn't keep them all. Its referral tells us who handles.com, and that next authority points us toward example.com's own servers. So each referral narrows who to ask, until a server with the relevant records supplies the address. Otherwise every changed website address would become the root's problem. And cached referrals shorten later searches. Cloudflare even documents hosting root information locally, so this cold walk doesn't mean every real lookup contacts a remote root.
3:52 Once we find an address, we save it with its identity and age. We keep the name, record type and class, which identifies the DNS data family. Our class is always Internet, as the record card shows. Private answers or other policy differences would also have to affect which entries can be reused. The record's time-to-live, or TTL, bounds ordinary reuse. Our 60-second answer received at zero has 40 seconds left 20 seconds later; we don't have to fetch a new answer on a schedule. My instinct is to reward a popular entry by restarting those 60 seconds whenever somebody reads it.
4:30 Wouldn't that keep useful answers ready to reuse? It could preserve an obsolete address forever. A hit doesn't restart its age, and publishing a new address doesn't instantly replace still-permitted older answers in everyone else's cache. With age tracked, an alias adds another record. The first card points our website name to another name, whose address appears in the second card. For example, the alias can last 60 seconds while its target address lasts 30. A refresh means fetching new data; updating the address doesn't renew the alias's own lifetime.
5:03 We follow the target and return the alias with the address, so the caller can connect that address back to the name it asked about. What if the second name points back to the first, like the loop underneath? Stop revisiting the cycle and bound the whole search. Also check which supplied records are relevant, so an answer can't smuggle unrelated addresses into our cache. But bounded searches can still multiply. Suppose 1,000 callers reach one worker while its first lookup is unfinished. Independent searches would multiply the same outside work.
5:34 The worker joins those callers onto one active resolution task, an unfinished search. Each caller takes a waiting slot in memory and has its own deadline, the time when it stops waiting. That shared task can ask several authorities or follow an alias. One logical lookup isn't necessarily one packet, and other workers can have their own copies. On the second view, caller A gives up while caller B is still waiting. Does A's deadline cancel the shared task? Only if nobody needs it anymore under our policy.
6:05 Remove A's waiting slot, keep B's work alive, and bound waiting callers separately from active tasks. Those shared searches lead to routing, choosing which worker gets a request. Within a nearby serving location, why not send every request for this name to one worker? A popular name could overload that worker while others have room. Randomly spreading every query is a reasonable way to share load, but it splits repeated questions across caches. So we favor a worker for reuse until it gets too busy, then route elsewhere.
6:37 That sacrifices some sharing to keep one popular name from concentrating the work. And if that worker fails, its replacement may need to look this name up again. The replacement is healthy; it just doesn't know that answer yet. Leave room for that recovery traffic. This worker can answer as soon as it learns the address from an authority; it doesn't wait for the others. But adding workers won't repair an authority that doesn't reply. Our upstream servers, the servers we query for information, need their own health observations and alternate choices.
7:09 Cloudflare describes using measured response performance and trying another authority when a server hasn't replied before its waiting limit runs out, a timeout. That's a server-choice decision, not evidence that the requested name has vanished. For example, authority A stays silent but authority B supplies an address. Bound each wait and the total resolution work, so asking again can't consume resources indefinitely. The alternate reply can finish that lookup. Asking the parent, the zone above it, can't repair that lower server, so don't turn a timeout into a referral loop.
7:41 DNS standards also limit repeated queries to the same server address and transport, the way packets are carried. Exact timeout values vary, but asking again indefinitely isn't a recovery design. That distinction leads to different caller outcomes. NXDOMAIN means the queried name is absent; SERVFAIL means the resolver couldn't complete its job. Our example name could also exist without the requested address record. That's an absence of the requested information, called NODATA, rather than an absent name.
8:10 Both authoritative absence answers can be useful to cache with their proper lifetimes. A timeout proves neither kind of absence, so we must remember it differently. But after our shared task fails, won't the very next caller start that expensive search all over again? A separate short-lived failure entry prevents that. The DNS standard on resolution failures requires this cache: matching requests avoid corresponding outside work until its entry expires, then can try again. Now protect the answers we're saving.
8:41 Match replies to the question and responsible server. An example.com server can't assign an unrelated example.net address just by including it. An unpredictable request identifier, the reply-matching number, and source port, our program's numbered receiving point for replies, make an attacker's guessed reply less likely to match. Those checks still can't prove origin. DNSSEC, the DNS security extensions, adds digital signatures. I tend to lump security and privacy together. Does it also hide the name?
9:11 No. A signature lets us check that data came from whoever holds the matching secret key. A public key checks the signature without revealing that secret. An attacker could sign a fake address with their own key. Why wouldn't that fool us? We don't start with their key. Start with a root key we already trust. The root's signed information identifies the key for.com, the first link highlighted on screen. The verified.com key checks its signed link to example.com. That link identifies the next key, which verifies the address record.
9:44 The attacker's own key has no verified path from our trusted root. That gives us a checked address. We call data authenticated when its origin has been verified. What if the branch isn't signed? Here, that parent is.com. It can give us signed information saying it has no signing link to example.com. We check that statement with the.com key we've already verified. Then we may return the child's address without claiming we've verified its origin. Could a failed signature on our signed path take that unsigned route too?
10:16 No. A missing or broken signature isn't that proof. When the chain requires a signature and its check fails, we return failure. If the link is readable, observers can read the lookup. Knowing who signed the data doesn't make its contents secret. Encrypted transport makes traffic unreadable to observers on the protected link, such as device to resolver. The resolver still sees the question. Link privacy and record verification do different jobs. But our signed answer still ages during an outage. Serve-stale means keeping an expired answer for possible use when we can't refresh it, with a retention limit on how long we keep that data.
10:55 Take the illustrative clocks on screen: ordinary reuse ends at 1 minute, signature validity at 1:30, and our retention at two. What can we do at 1:20? That answer is stale, but its signature hasn't expired. It can pass that time check and, if the other checks and our outage policy allow, still be returned. By 1:40, we still have the record but its signature has expired. Our design can't call it authenticated just because retention hasn't ended. Nor does an invalid new reply become trustworthy because we saved an older one.
11:27 Retention, signature checks and our decision to answer remain separate controls. And if the address changed while we couldn't refresh, aren't we still sending callers to the wrong machine? We might be. Stale data buys a limited chance to answer, with that risk. Replace it when a proper refresh succeeds; it can't help a name we've never cached. With that limited safety net, consider a flood of different questions. Joining helps 1,000 copies of one name, but distinct names can each need their own search.
11:57 The worker hits its search limit while the waiting-caller gauge still looks comfortable. This flood creates separate work, so a limit on callers sharing one task won't contain it. Keep separate limits on tasks, waiting callers, cache memory and outgoing queries. Reserve room for our saved example-name answer, so new searches don't crowd out that cheap reply. Suppose the cache hit rate still looks healthy. Would that tell us the service is answering well? No. Split fresh, eligible stale, absent and failed outcomes.
12:28 Then lookup time, rejected signatures and authority health help explain whether the worker is overloaded or outside replies are failing. Now test those choices against a real incident: the outage in Germany's dot de naming zone in May 2026. Its operator, DENIC, reported defective code for replacing signing keys. Their test used one signing device, while the signing system in use had several. DENIC's final report says the defect appeared with several, so the test never exercised the failing setup.
12:57 Cloudflare's account describes retained stale answers cushioning some impact, followed by operators temporarily skipping signature checks for dot de. Those were different interventions, with different consequences. Skipping those checks could restore answers while reducing protection against forged data. That's a deliberate operator choice under pressure, not an automatic next step after an ordinary timeout. And our proposed resolver keeps verification strict. The incident shows why availability and trust need separate decisions, rather than treating every error as a request to try harder.
13:30 Finally, return to the same map. Our repeated name can take the saved-answer path, but only while the entry's age and trust checks allow it. An unfamiliar question starts or joins a search. Follow the responsible servers, check their replies, and keep records we're entitled to reuse without merging callers' deadlines. If that path fails, try eligible alternatives within the work budget. Remembered failure prevents an immediate repeated search; a separately eligible old answer can sometimes keep us answering.
13:59 We can follow the whole name-to-address request and explain why each outcome is allowed. The address still doesn't promise that the website will load. Thanks for listening to Learning Podcasts.