On this page
What you need first
This lesson uses ideas from these earlier lessons. Read them first if any idea is new to you.
01Why interviewers ask this
Interviewers ask: "How do you move the site to a new server with no downtime?" Or: "How do far-away users reach a near server?" Both start with DNS.
A weak answer says "DNS gives the address". A strong answer says how long the old address stays in use, and how to make that time short.
02The idea in plain words
Think about a phone book. A helper looks up a number for you and remembers it. If the helper does not know a number, the helper asks the office that owns the book.
Two kinds of DNS server turn a host name into an IP address (lesson 7). A resolver looks names up for you and keeps each answer for a while. An authoritative server holds the official list for your domain.
Records
A record is one line in that list: a name, a type, a value and a TTL. (IN means the internet. Ignore it.)
results.example.in. 300 IN A 203.0.113.10| Type | The value is |
|---|---|
| A, AAAA | An IP address (AAAA is for the newer, longer kind of address) |
| CNAME | Another name: a second name for the same place |
| MX | The mail servers |
| TXT | Plain text, for example to prove you own the domain |
| NS | The authoritative servers |
A name that has a CNAME cannot have any other record. The plain domain example.in always has NS records, so it cannot be a CNAME.
TTL
TTL (time to live) is the number of seconds that a resolver may keep an answer and reuse it. The record above has a TTL of 300 seconds.
- A long TTL means fewer lookups. The cost: a change reaches users slowly, because old answers stay in use.
- A short TTL means a change spreads fast. The cost: more lookups.
Nobody can take back an answer already given. Some programs keep answers longer, so wait a little longer (our own advice).
Geo routing
With geo routing, the authoritative server picks its answer by where the asker is. Askers in India get a Mumbai server. Askers in Germany get a Frankfurt server. Round trips (lesson 7) get shorter.
The limit: the server sees the address of the resolver, not of the user. A user of a far-away resolver may be placed wrongly. EDNS Client Subnet helps: the resolver shares part of the user's address.
Stuck on something? The AI tutor has read this lesson. Ask it with a free account
03Pause and predict
Pause. Guess first.
A record has a TTL of 3,600 seconds. You change its address at 10:00. By what time do all resolvers that follow the TTL use the new address?
Write your guess before you read on. The answer is in the worked example.
04Worked example
The site results.example.in moves to a new server. Assumptions (made up to teach with): TTL 3,600 seconds.
Step 1: change at once. A resolver that stored the answer at 09:59:59 keeps it until 10:59:59, so the last users move at about 11:00. This answers the predict box. For up to 60 minutes, some users reach the old one.
Step 2: a better plan.
- At least 3,600 seconds before the move, lower the TTL to 60 seconds.
- Change the address. Keep the old server running.
- After a few minutes, switch the old server off and raise the TTL.
Old answers now last at most 60 seconds.
Step 3: the price. Assumption: 5,000 resolvers ask for this name, once per TTL. At TTL 3,600 that is 5,000 / 3,600 = 1.4 questions per second. At TTL 60 it is 5,000 / 60 = 83 (60 times more).
Step 4: geo routing. Assumption: from India, the round trip is 30 ms to Mumbai and 150 ms to Frankfurt. A first request needs 2 round trips and 20 ms of work (lesson 7), not counting the DNS lookup.
- Sent to Mumbai: 2 x 30 + 20 = 80 ms.
- Sent to Frankfurt by mistake: 2 x 150 + 20 = 320 ms (4 times slower).
05Trade-offs
- A short TTL solves slow change. It costs more lookups. I would use it only around a planned move.
- Geo routing solves long round trips. It costs extra records and some wrong answers. I would change it if many users are placed wrongly.
- DNS solves finding a server by name. It costs slow change: some programs keep old answers longer than the TTL. I would not rely on DNS alone for a switch that must finish in seconds.
06Common misconceptions
"I change the record and everyone sees the new server at once." Stored answers live until the TTL ends: up to 60 minutes here.
"I lower the TTL just before the move." Resolvers hold the old answer for the old TTL. Lower it one old TTL earlier.
07How to say it in the interview
Say it like this
Before a move, I would lower the TTL to 60 seconds, one old TTL ahead of time, because DNS cannot take back an answer. Then I change the record, so old answers last a minute at most, and I raise the TTL again.
08Check your understanding
- What are a TTL and a CNAME? What does geo routing do?
- A TTL is 1,800 seconds. You change the address at 09:00. (a) When do all resolvers that follow the TTL use it? (b) 20,000 resolvers ask once per TTL. How many questions per second at TTL 1,800, and at TTL 30?
- A team moves on Saturday at 02:00. The TTL is 86,400 seconds. When must they lower it?
09Answers
Show the answers
- A TTL is how many seconds a resolver may keep an answer. A CNAME makes a name an alias of another name. Geo routing gives each asker the answer for their place.
- (a) 09:00 + 1,800 seconds = 09:30. (b) 20,000 / 1,800 = 11 per second (rounded from 11.1). 20,000 / 30 = 667 per second (rounded from 666.7).
- One old TTL before: 86,400 seconds is 24 hours, so by Friday 02:00, to 60 seconds.
10Sources
- RFC 1035 (records, TTL), RFC 3596 (AAAA), RFC 2181 section 10.1 (CNAME), RFC 7871 (EDNS Client Subnet), at https://www.rfc-editor.org/ (opens in a new tab). Geo routing: https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/routing-policy.html (opens in a new tab). Checked 20 Oct 2026.
Try it now, no sign-up
Related lessons and practice
Ask the AI tutor about this lesson
The tutor has read this lesson. Ask in your own words, any time. Free account, 20 questions a day.
Reading never needs an account. The account is for the tutor, the quiz, your notes and your progress.