DNS Resolution a show in 8 chapters
Goal: turn any name into its address with no master list, fast
1 of 8 Your guess
Before we start
You type example.com and a page appears. That is a name. Before anything is sent, your computer needs a number, an address like 104.20.23.154, because the wires deliver only to numbers.
Which picture is closest to how your computer finds that number?
Pick the closest. You find out which fits at the end.
8lines in the file
one line per machine: its name and its address
64lines copied for one new machine
8 machines × 8 lines each = 64
1phone call to Menlo Park
business hours only, and a person types the line in
Example sizes. The lesson says one file worked at a few hundred machines.
2 of 8 The problem
1970s: one file for the whole network
Before the early 1980s, every computer on the ARPANET, the network the internet grew from, kept the same copy of one file: HOSTS.TXT. Its only job was saying which name belonged to which machine.
To add a computer, you phoned the Network Information Center at the Stanford Research Institute in Menlo Park, in business hours. A person typed your line into the master copy. Every other machine then fetched the whole file again to see it.
8 machines. Double the network and watch the copying.
Your goal: turn any name into its address with no master list anywhere, and fast, however big the network gets.
What changed
- Lines copied for each new machine: 64 → 65,536
By the early 1980s the network was growing every week, and the phone call and the retyping could not keep up.
Why multiply?
Every machine fetches the whole file, and the file has one line per machine. So each of the machines copies that many lines.
3 of 8 The idea
1983: a system with no list at all
The fix landed on Paul Mockapetris, at the University of Southern California's Information Sciences Institute. Not a bigger, faster list. No complete list anywhere.
First, the two things it connects. A name is chosen by a person and can point somewhere new tomorrow. An address belongs to whoever rents that slice of the network right now.
Instead of one list, small books, each kept by a different office. Each book holds one piece, plus who to ask next.
The root is 13 machines, the directory of the whole internet. The .com registry knows who looks after each .com name. The name's own server keeps that name's own book: it is the authoritative server.
Two of the three books never hold the address. They say "I don't know, ask them". That answer is a referral.
Referrals are the whole mechanism. Nobody at any level knows everything, so the system Mockapetris built in 1983 kept working on a network now billions of machines larger.
This whole system is DNS, the Domain Name System.
time so far: 0 ms
Measured once in the lesson, on a real lookup of example.com.
Your laptop to the concierge, 1 question
"Do the whole job. Come back with the address."
RD = 1 · recursive
The concierge to each office, 3 questions
"Tell me what you know. If that is 'ask them', fine, I will go there myself."
RD = 0 · iterative
1 question from you · 3 from the concierge: root, registry, server
The root's reply, asked with RD = 0
answers0no address for example.com
who to ask13.com servers, by name: a.gtld-servers.net to m.gtld-servers.net
extra27records nobody asked for: those servers' addresses
the counts the root's reply carried in the lesson: 0 answers · 13 names · 27 extra records
4 of 8 Try it
Be the concierge
A hotel concierge makes however many calls it takes and comes back with one answer. In DNS that is the resolver, usually run by your internet provider, or a public one like 8.8.8.8. You are the concierge now.
Times are in ms, milliseconds: a thousandth of a second each. The button below makes one call at a time.
Your laptop asks the concierge one thing: example.com? The concierge doesn't know. It needs somewhere to start.
What changed
- Time to find one address: unknown → 180 ms
27 + 51 + 84 + 18 = 180 ms, about a fifth of a second, for one name with nothing noted anywhere.
You asked one thing and got a finished answer. That kind of question is recursive. The concierge's questions only ask "what do you know": they are iterative.
One flag in the question tells them apart: RD, recursion desired. Yours carries RD = 1. The concierge's carry RD = 0.
Why would the root answer anyone?
It costs the root almost nothing: no walking and no memory, one instant reply that says who to ask next.
The root's referral names 13 .com servers. To reach one by name, you would have to look its name up first, under .net, which is another walk.
So the reply carries their addresses too, unasked. Those extra records are glue: they break the chicken and egg.
The lesson asked 1.1.1.1 for openbsd.org, three times in a row
1st ask
2nd ask
3rd ask
300 s ÷ 60 = 5 minutes
with no notes: 12 names × 180 ms = 2,160 ms, over 2 seconds, if a page's names were walked one after another
example.com, asked once a second
1 ask a second × 300 seconds = 300 asks while one note lasts · 1 walk, then 299 answered from the note · 1 − 1 ÷ 300 = 99.7% from the note · 180 ms ÷ 300 asks = about 0.6 ms of walking per ask, on average
- Your browser's notesinside the browserno note, ask the next
- Your computer's notesthe operating systemno note, ask the next
- The concierge's notesthe resolver, one trip awaynote found: stop here
- The walkroot, .com, server: 180 msnever asked
5 of 8 The fix
The sticky note
A full walk took 27 + 51 + 84 + 18 = 180 ms in chapter 4, and one page can touch a dozen names. So the concierge writes each answer on a sticky note before handing it back. The next person asking the same question gets the note.
The lesson asked a public concierge, 1.1.1.1, for openbsd.org three times in a row.
Press Play to ask three times.
A note doesn't last forever. It says how many seconds it may be trusted: example.com's says 300. When that runs out, the note is thrown away and the next ask walks again.
That keep-for number is the TTL, time to live.
What changed
- Same question, asked again: 435 ms → 14 ms
How much does one note save? It depends how many asks arrive while it lasts. The first ask walks, every other one reads the note. Pick how often a name is asked, and its TTL.
The concierge is not the only one keeping notes. Your browser keeps some, and so does your computer. A lookup asks them in order and stops at the first note. Only a miss at every one walks the chain.
Each note keeper is a cache. Where is the note?
wikipedia.org's TTL from 1.1.1.1, asked once a second
900 s ÷ 60 = 15 minutes, a quarter of an hour
One reply, asked for www.github.com
1,209 s ÷ 60 ≈ 20 minutes · 60 s ÷ 60 = 1 minute
Example: an old TTL of 24 hours, the case in the lesson's own question.
6 of 8 The cost
Many notes, many clocks
A note's time left should fall by 1 every second. The lesson asked for the same name's TTL once a second, eight times. Watch it count down.
Press Play to ask once a second.
1.1.1.1 was never one machine. It is one address answered from hundreds of sites, with many machines behind each. Every machine keeps its own note, written at its own moment.
Each ask can land on a different machine and read a different note. So a changed record reaches people at different times: every note runs its own clock.
Finding out a name does not exist costs a full walk too: the concierge has to reach the authoritative server to be told no. So the no gets a note as well.
The reply for no such name is NXDOMAIN. A brand new name tried a minute too early can stay unreachable on that machine until its note runs out.
Ask for www.github.com and the reply holds two notes: a forwarding note, then github.com's own address. A forwarding note is a CNAME.
"www is really us" almost never changes, so it keeps for 20 minutes. The address might change in the next minute, in a deploy or a failover, so it keeps for 1.
A low TTL re-asks often but a change lands fast. A high TTL walks less but a change lands slowly.
Moving a name to a new address next week? Lower its TTL a full day ahead, so the long notes run out while nothing is happening. Then switch, then raise it back.
Lower it on moving day instead, and every note written yesterday still holds yesterday's TTL. Those notes keep the old address for as long as it said.
7 of 8 Your guess
Your picture now
Goal met: no master list anywhere. A full walk is 180 ms, a note is 14 ms, and on a busy name with a 300 second TTL only 1 ask in 300 walks. Which picture is closest now?
Pick one.
c is DNS. a is HOSTS.TXT, the file DNS replaced in 1983. b never existed: no machine anywhere knows every name.
8 of 8 Keep this
Keep this
Nobody keeps the whole list. You ask one concierge, who follows referrals from the root down to the name's own server, then keeps the answer on a note for its TTL.
The price: a change reaches people only as their notes run out, each on its own clock. Lower the TTL a day before a move.
Read the full lessonComing up Every question the concierge asked and every reply it got was a message a few dozen bytes long. Next: read one, byte by byte, and find the 512-byte limit DNS has lived under since 1987.