SevyDevy

Module 1 · How an App Answers a Tap · Lesson 3 of 35

How does DNS work? How a phone finds the right server

11 minFree System design course · Beginner to intermediateLesson 1.3By Saket Bhatnagar

Researched and drafted with AI, reviewed and edited by Saket Bhatnagar.

In short

  • How does DNS work? Your phone asks a helper, which asks a chain of servers until one gives the server’s address.
  • The helper remembers that answer for a set number of seconds, so the next look-up skips the chain.
  • That memory makes the web fast and changes slow: a new address reaches everyone only when every old copy has run out.
Soon

Video lesson · coming soon

How does DNS work? The one-hour memory

Lala, your AI mentor, will walk you through this lesson in a short animated video. Until then, everything is here to read and try.

  1. 01 Saved, but half the club is stuck
  2. 02 The watchman who remembers
  3. 03 Follow one look-up
  4. 04 The chain and the sticky note
  5. 05 Lower the TTL a day early
  6. 06 Next: what the phone says

On Saturday morning, Meera Kulkarni moves SeatJaldi, app and seat database together, to a new ₹1,200-a-month server. She types the new address into her control panel and sees “Saved”. She switches the old ₹1,200 server off. On her laptop, the app works.

Then her phone rings. “The app is down,” one member says. Another booked a ₹299 seat a minute earlier. Out of 100 club members, some could book and some could not.

Arjun Nair stares at the panel. “But it says Saved!” For about an hour, many phones keep knocking on the old, switched-off address. Why?

How does DNS work?

DNS turns a name like seatjaldi.in into a server address by asking a chain of servers, then remembers the answer for a set time.

Your phone has its own Ramulu. It does not find the number itself; it asks a helper, usually run by your mobile or Wi-Fi company.

Like Ramulu, the resolver does not remember forever. Each answer comes with a timer, counted in seconds.

The one idea to keep: names are looked up once and then remembered for a while, and “a while” is the TTL.

  • Look up once: the resolver asks the chain of servers for the address.
  • Remember for a while: it keeps the answer for the TTL, counting down.
  • Change slowly: a new address reaches a resolver only after its old copy runs out.
Try it yourselfMyth or fact: DNS changesGuess first, then turn each card over.
  • A new website pauses the first time, then opens instantly. Only the first visit did the whole look-up.
  • A friend’s new site “cannot be reached” for you, then works an hour later. Your resolver asked before the site was ready, and remembered “no such name”.
  • A company moves its website, and some people see the old site for hours. Their resolvers still hold the old answer.

What are the DNS resolution steps?

The phone asks its resolver, and the resolver asks the root server, then the .in server, then SeatJaldi’s name server, which gives the address.

So DNS is not one big server. It is a chain, asked one link at a time, like Ramulu going from office to desk.

Try it yourselfFollow one DNS look-up, then a second oneStep through how a phone finds seatjaldi.in, and watch the second look-up skip the chain. Every number is made up for teaching.

So the first look-up asked four servers, and the second asked only the resolver, like Ramulu answering at the gate. Real resolvers often remember the .in step too.

The look-up chain and the resolver’s memory

The resolver itself asks the root server, the .in server and SeatJaldi’s name server in turn. It keeps the answer for the TTL, so the next phone is answered from memory.

Diagram connections:

  • Phone to Resolver (Where is it?)
  • Resolver to Root server (1. Asks root)
  • Resolver to .in name server (2. Asks .in)
  • Resolver to SeatJaldi name server (3. Asks SeatJaldi)
  • SeatJaldi name server to Resolver’s memory (Address, TTL 3600)
  • Resolver’s memory to Phone (Address)
  • Next phone to Resolver (Asks later)
  • Resolver’s memory to Next phone (From memory)
  • Phone: Knows only seatjaldi.in.
  • Resolver: Asks each server in turn for the phone.
  • Root server: Points to the .in servers.
  • .in name server: Points to SeatJaldi’s name server.
  • SeatJaldi name server: Holds the real answer: the address and its TTL.
  • Resolver’s memory: Part of the resolver; keeps the answer for 3600 seconds.
  • Next phone: Asks a minute later and is answered at once.

What is DNS TTL, and why do changes feel slow?

The TTL is a countdown on every stored answer, so a change can take up to one full TTL to reach everyone. And no, not everyone sees it at once: each resolver’s clock started when it last asked.

The resolver’s memory is a cache, and so is Ramulu’s. If Ayesha moves flats, Ramulu sends visitors to Flat 304 until his memory runs out.

TTL 3600 vs TTL 300
QuestionTTL 3600 (one hour)TTL 300 (five minutes)
Worst-case wait after a changeUp to one hourUp to five minutes
Look-ups per resolver per hourUp to 1Up to 12 (3600 ÷ 300)

Resolvers also remember “no such name”, for a time the name’s owner sets. If Ramulu has told a visitor “no Ayesha here”, he keeps saying it for a while after she moves in.

Meera clicked Saved at 10:00. That changed the record on SeatJaldi’s name server, but the TTL was 3600 seconds. One member’s resolver had asked at 9:58, so it kept the old address until 10:58.

Another had asked at 9:15, so its copy ran out at 10:15 and it got the new address. Meera’s laptop worked because its resolver had no copy, so it asked fresh.

How do you choose a TTL, and what if DNS fails?

Pick a TTL by how fast you may need to change, and lower it ahead of any planned move. Short means faster change and more look-ups. Long means fewer look-ups, slower change, and stored answers that keep working longer if your name servers fail.

A good society tells Ramulu a day early, “Trust your memory for five minutes only.” Then Ayesha moves.

text
; the same record on three days: name, TTL, IN, A, address
seatjaldi.in.   3600  IN  A  203.0.113.25   ; normal day
seatjaldi.in.   300   IN  A  203.0.113.25   ; a day before: TTL lowered
seatjaldi.in.   300   IN  A  203.0.113.40   ; moving day: new address

What just happened? The TTL dropped a day before the address changed, so the move took five minutes at most.

Even then, keep the old server on until its traffic stops. Open connections, and apps that keep their own copy of the address, can outlast the TTL. If it still holds any bookings, have it forward each new request to the new server, so every booking lands in one place.

DNS is also something your app quietly depends on, because your app finds its database by name too.

If the database endpoint’s look-up fails, the database looks gone. In October 2025, a large cloud provider’s outage began when its own automation left a database’s DNS record with no address in it. The record was fixed in under three hours, but the knock-on failures took about fourteen and a half hours to clear.

So check your important names often, and know what your app does when a look-up fails.

  1. Run the look-up

    Open a terminal (Command Prompt on Windows) and run nslookup -debug example.com, a name kept for examples. Find the line example.com, type = A, and write down the ttl under ANSWERS below it: the TTL in seconds.

  2. Run it again

    Run it three more times and write down each ttl.

  3. Work out the worst case

    If the owner changed the address now, a resolver could keep the old one for at least the biggest ttl you saw.

  4. Check your answer

    You are right if your worst case is that biggest ttl, not zero. The numbers can drop, stay put or jump, because a fresh copy was fetched or another resolver machine answered.

So that is how a phone that knew only seatjaldi.in found the server’s address. Meera’s one-hour wait was a watchman with a one-hour memory.

Next time she will lower the TTL to 300 seconds a day early, move, and keep the old server on until its traffic stops. The worst wait drops to about five minutes, and afterwards she raises the TTL back to 3600.

Arjun nods, then frowns. “The phone has the address now. But the app and the server only work if both sides agree on what the app may ask and what each answer means. Where is that agreement written down?”

Check yourself

Check yourself

At 10:00 Meera changes the address. The old TTL was 3600 seconds. By when will every resolver have the new address, at the latest?

Pick an answer to see why it is right or wrong.

Check yourself

Meera plans another move tomorrow. What should she do?

Pick an answer to see why it is right or wrong.

Remember these three

  1. Names are looked up once and then remembered for a while, and “a while” is the TTL.
  2. A change reaches each resolver only when its old copy runs out.
  3. Lower the TTL a day before a move, keep the old server on until its traffic stops, and monitor DNS.

Questions people ask

How does DNS work?
Your phone asks a resolver for the address. The resolver asks the root server, then the server for the ending, such as .in or .com, then the site’s name server. It keeps the answer for the TTL.
What is DNS TTL?
TTL is the number of seconds a resolver may keep a DNS answer before asking again. A lower TTL means faster changes, but more look-ups.
Why does a DNS change take so long to show up?
Resolvers keep the old answer until its TTL runs out, and each one switches at its own time. In the worst case, the wait is one full old TTL.