Stage 1 · Foundations · Easy · 12 min
DNS and geo-routing
DNS turns a name such as shop.example.com into a server's IP address. Follow one lookup, see why answers are cached, and how DNS sends users to a nearby region.
What each interview level is expected to know
Learn first: The client–server model
After this lesson you can:
- Follow one DNS lookup from the local cache to the server that holds the answer.
- Predict how long an old address keeps being used after a change, from its TTL.
- Explain how one name can send users in different places to different regions.
Start here
See it in 60 seconds
Finding the address behind a name
DNS finds the address behind a name by asking a chain of servers once, then answering from a saved copy until its TTL runs out.
Scene 1 of 6 · Ask the resolver
Your browser needs the address for shop.example.com, so it asks a resolver, a server that looks names up.
- Your browser — healthy
- Resolver — healthy
- Root server — healthy
- .com server — healthy
- Name server — example.com — healthy
- This lookup took about
- not shown yet
- Ask the resolver. Your browser needs the address for shop.example.com, so it asks a resolver, a server that looks names up.
- Ask a root server. The resolver asks a root server, which knows only where the .com servers are.
- Ask the .com server. A .com server knows which name server keeps the records for example.com.
- Get the address. That name server answers 203.0.113.7, and says to keep it for 300 seconds: the TTL.
- Answer and remember. The resolver passes the address back after about 110 ms, and keeps a copy until the TTL runs out.
- The next lookup is quick. For the next 300 seconds, anyone using this resolver gets the address from its copy in about 20 ms.
- Now you try. How long ago did this resolver last look up shop.example.com? Set the seconds. For example: 120 s is under the 300 s TTL, so the resolver answers from its copy in about 20 ms. The copy stays good for 180 more seconds; after that, the next lookup takes the full trip again.
Scene 1 of 6: Ask the resolver. Your browser needs the address for shop.example.com, so it asks a resolver, a server that looks names up.
Key points
- DNS turns a name such as shop.example.com into an address a computer can connect to.
- A full lookup asks a root server, then a .com server, then the site's own name server.
- Resolvers keep each answer for its TTL, so most lookups take one short trip.
- A long TTL means fewer slow lookups, but a changed address takes longer to reach everyone.
In plain words
You type shop.example.com into a browser. The network cannot route to a name: it needs a number, such as 203.0.113.7. That number is an (The number that identifies a machine on a network, such as 203.0.113.7. Packets are sent to it.). The (The Domain Name System: the way the internet turns a name, such as example.com, into the address of a server.) (DNS) is the lookup service that turns the name into the address. The browser gets the address first, then connects to the server.
The lookup takes a few steps. The browser asks a (A server that looks up names for you. It asks other DNS servers in turn, then keeps each answer for a while.), usually run by the internet provider. If the resolver has no saved answer, it asks the root servers, then the servers for .com, then the shop's own name servers. Browsers and resolvers keep the answer for a set time, its (How long a cached copy is kept before it is thrown away.), so later lookups skip all of that.
The problem it solves
People remember names, but networks route by number. A site's address also changes: it moves to a new host, or adds servers in other regions. DNS lets the name stay the same while the address behind it changes.
Why it matters
A client must look up a name in DNS before it can connect, so DNS sits in front of almost every system. The lookup adds a delay to the first request. DNS can also send each user to the nearest region, and move traffic away from a failed one. When DNS fails, users without a cached answer cannot find the site, even if its servers are healthy.
A worked example
Suppose a domain's DNS answer has a TTL of 300 seconds, and a browser sends one request every second. One real DNS lookup then covers the next 299 requests, since 300 − 1 = 299, before a new lookup is needed.
Think of it like…
Think of the contacts list on your phone. You tap a name, and the phone dials the number stored for it. You never need to remember the number.
Where this analogy stops working
A name that maps to a number is the useful part. But DNS is not one list in one place. A resolver asks a chain of servers, and each knows only the next step. Answers are also cached, so after a change some users get the old address for a while.
Try it
See it working
Mechanics
How it works
DNS turns a name into an address. The pictures follow one lookup: a browser asks for shop.example.com, and the answer is 203.0.113.7.
Check local caches
DNS turns a name such as shop.example.com into an IP address such as 203.0.113.7. The browser first checks its own (A small, fast store that keeps copies of popular data, so most reads skip the slower database.), then asks the operating system. If either has the answer, no network call is needed.
Ask a recursive resolver
If not, the computer asks a recursive resolver. This is a server, often run by your internet provider, that finds the answer for you. It answers from its own cache when it can. With nothing cached, it starts at a root server.
Follow the chain
Pick a case to follow belowWith this case: With nothing saved, the lookup took 4 trips and about 110 ms before the browser could even connect.
Browser, wants the address Browser wants the address Resolver, finds it, saves it, NOW Resolver finds it, saves it nothing saved NOW Root server, knows .com, .org… Root server knows .com, .org… .com server, knows example.com .com server knows example.com Name server, for example.com Name server for example.com - Browser — wants the address — healthy
- Resolver — finds it, saves it — healthy — NOW — nothing saved
- Root server — knows .com, .org… — healthy
- .com server — knows example.com — healthy
- Name server — for example.com — healthy
- Question
- Answer
Step 1 of 5Step 1 of 5 · Resolver
Done: The browser asks the resolver
- What happens
- The browser and the computer have nothing saved for shop.example.com, so the computer asks its resolver.
- Why
- The resolver does the searching, so the computer sends only one question.
- What changes
- The resolver has nothing saved either.
- Next
- The resolver asks a root server
Time so far10msTrips over the network1Address found–Step 1 of 5: Resolver. The browser asks the resolver. The browser and the computer have nothing saved for shop.example.com, so the computer asks its resolver.
The root server points to the servers for .com. Those are top-level domain (TLD) servers. The .com server points to the authoritative name server for example.com. That server holds the real record and returns the IP address.
In the picture, each trip from the resolver to a name server takes about 30 ms there and back. These are round example times, not measurements. With nothing saved, the lookup takes four trips and about 110 ms.
Switch to the resolver having the answer saved. Then the lookup is one trip of about 20 ms. When the browser has it saved, nothing goes over the network. That is why most lookups are fast: someone nearby asked for the same name a short time ago.
Return and cache the answer
Pick a case to follow belowWith this case: With a TTL of 300 seconds, users of this resolver get the old address for up to 240 more seconds. In return, it asks the name server less often.
Browser, wants the address Browser wants the address Resolver, finds it, saves it Resolver finds it, saves it saved 203.0.113.7 Root server, knows .com, .org… Root server knows .com, .org… .com server, knows example.com .com server knows example.com Name server, for example.com, NOW Name server for example.com now 203.0.113.50 NOW - Browser — wants the address — healthy
- Resolver — finds it, saves it — healthy — saved 203.0.113.7
- Root server — knows .com, .org… — healthy
- .com server — knows example.com — healthy
- Name server — for example.com — healthy — NOW — now 203.0.113.50
- Question
- Old answer
Step 1 of 3Step 1 of 3 · Name server
Done: The shop moves to a new server
- What happens
- The name server for example.com now says 203.0.113.50. The old server, 203.0.113.7, is switched off.
- Why
- Nothing tells the resolvers. Each one finds out only when it asks again.
- What changes
- The resolver still holds the old answer it saved 60 seconds ago.
- Next
- A browser asks for shop.example.com
Name server says203.0.113.50Resolver saved203.0.113.760 s ago, TTL 300 sBrowser gets–not yetStep 1 of 3: Name server. The shop moves to a new server. The name server for example.com now says 203.0.113.50. The old server, 203.0.113.7, is switched off.
What these pictures simplify. These pictures use round example times: 20 ms to the resolver and back, 30 ms to each name server and back. Real times depend on where the servers are. A real resolver runs on many machines, and a browser may cap how long it keeps an answer.
The resolver sends the IP address back with a time to live (TTL), such as 300 seconds. Each cache on the way keeps the answer for up to that long. A short TTL lets you change the address quickly, but causes more lookups.
In the picture, the shop moves to a new server, 203.0.113.50, a minute after the resolver saved the old address. Nothing tells the resolver about the move.
With a TTL of 300 seconds, the resolver keeps handing out the old address for four more minutes. With 30 seconds, its copy has run out, so it asks again and gets the new one. The cost is that it asks up to 10 times as often. Teams often lower the TTL a day before a planned move, then raise it again after.
One name, different answers
The name server does not have to give everyone the same address. With geo-routing, it looks at where the question came from and returns the address of the nearest region. Say the site runs in Frankfurt and Singapore. A user in Paris gets the Frankfurt address, and a user in Jakarta gets the Singapore one.
The question usually comes from the user's resolver, not from the user. So the name server guesses the user's place from the resolver's address. A user far from their resolver can be sent to the wrong region. Some resolvers pass on part of the user's address to fix this, a feature called EDNS Client Subnet.
Use it when
- Sending each user to a nearby region (geo-routing): the name server answers with the address of a region near the user.
- Moving traffic away from a failed region: point the record at a healthy one, and users follow as their cached answers run out.
- Keeping one fixed name in front of servers you replace: clients keep using the name, and only the record changes.
Skip it when
- Fast (Switching to a backup, such as promoting a replica to primary, after the original one fails.) between single servers: clients keep a dead address until its TTL ends. A (A server that receives every request first and passes each one to one of several servers behind it.) with health checks reacts much sooner.
- Finding copies of a service that start and stop all day: a cached answer is soon out of date. A (One place that keeps the list of a service's live copies and their addresses. Copies add themselves, and callers ask it by name.) with (A small "I am alive" message sent again and again at a steady interval, to show that a server or connection still works. The interval depends on the system: milliseconds in some, seconds in others.) fits better.
Check yourself
Judgement
Trade-offs and how it fails
What you give up
- Performance
- A long TTL means fewer lookups, so most requests skip the DNS delay. A short TTL means more lookups, but a changed address reaches users sooner.
- Consistency
- After a change, each user keeps the old address until their cached answer runs out. So for a while some users reach the old servers and some the new. That lasts about one TTL, and longer where a resolver or an app ignores the TTL.
Failure modes
- The DNS provider goes down. In October 2016 an attack flooded the provider Dyn with traffic. For hours, many users could not reach Twitter, Netflix or Reddit, though those sites' own servers were running.
- A wrong record with a long TTL. Resolvers keep the bad address for up to the full TTL, and you cannot clear most of their caches.
- Failover slower than planned: some resolvers and apps keep an answer past its TTL, so some users still reach the dead address.
- Geo-routing picks the wrong region: the name server often sees only where the resolver is, not where the user is.
In the real world
- AWS Route 53 offers latency-based routing, which answers each user with the region that responds fastest for them. Source: AWS Route 53 docs: latency-based routing (checked 14 October 2026)
- Public resolvers such as Cloudflare's 1.1.1.1 use anycast: one IP address is announced from many cities, so queries reach a nearby server.
Trade-offs to be ready to discuss: Dns ttl tradeoff
Check yourself
Interview
What interviewers look for
- When you fail over through DNS, state the TTL and what it costs: "With a 60-second TTL, most users move within about a minute."
- For a multi-region design, say how users reach the nearest region: geo-routing in DNS, or anycast, where one IP address is announced from many places.
Say it out loud: What changes if you set a DNS TTL to 1 second, or to 86,400 seconds (24 hours)?
Expected depth by interview level
Levels describe the depth interviewers probe, not years of experience. Choose a level on the learning path to highlight it.
- JuniorExpected
- What DNS does and why answers are cached.
- MidExpected
- TTLs and DNS-based routing.
- SeniorUseful
- Geo-routing and failover through DNS, and the TTL delay.
- StaffUseful
- DNS as one piece of a multi-region failover plan.
Practice
Apply it
Three harder questions
The first two use the idea on a new case. The last asks you to judge a design.
Apply it
Apply it
Judge a design
Go deeper
Sources and further reading
First-hand sources to check this page against and to go further. They are standards, official docs, original papers, and guides from engineering and security teams. Each link was opened on 8 November 2026.
- StandardRFC 1034: Domain Names, Concepts and FacilitiesIETFThe original design of DNS: the name tree, name servers, resolvers and caching with TTLs.
- Official docsWhat is a domain name?MDN Web DocsHow a name is built from levels, and how a DNS lookup turns it into an address.