Every time you visit a site, something invisible has to happen first: the human-friendly name (vibeengines.com) must become a machine address (an IP). There is no single directory of the whole internet — that wouldn’t scale — so DNS is a distributed, hierarchical tree, and looking up a name is a small journey through it. Your device asks a recursive resolver (often your ISP’s or a public one like 1.1.1.1), and that resolver does the legwork: it asks a root server, which doesn’t know the answer but points it to the right top-level-domain (TLD) server; the TLD server points it to the domain’s authoritative server; and the authoritative server finally returns the address. Each step is a referral down the tree. Then — crucially — the resolver caches the answer for its time-to-live, so the millions of later lookups are instant. Resolve a name step by step, then look it up again and watch the cache short-circuit the whole journey.
recursive walk · root → TLD → authoritative · referrals down the tree · then cache (TTL)
recursive resolver
The server (your ISP’s or a public one) that does the full lookup on your behalf and returns the final answer.
root server
Top of the tree. Knows nothing about domains directly — refers you to the correct TLD server.
authoritative server
Holds the actual records for a domain and returns the real address.
TTL
Time-to-live: how long an answer may be cached before it must be looked up again.
resolve.js — walk the tree, then cache
Ready
Your resolver must turn www.vibeengines.com into an IP. It has no idea where to look, so it walks the tree from the top. Press Ask ▸ to send the next query, or Resolve to run the whole journey. Then look it up again and watch the cache.
0
network hops
empty
cache
—
answer
How it works
DNS is a lookup system that had to work for the entire internet without any single machine holding the whole map, so it is built as a hierarchy of delegation. The name www.vibeengines.com reads right-to-left as a path down a tree: the root (the implied trailing dot), then the com TLD, then vibeengines, then the www host. No server knows the whole tree — each level only knows how to refer you one step down. A recursive resolver chains those referrals: it asks a root server (“who handles com?”), gets a referral to the TLD servers, asks them (“who handles vibeengines.com?”), gets a referral to the domain’s authoritative servers, and asks them for the actual record. This delegation is also how ownership works — buying a domain means the TLD registry points its referral at your authoritative servers. The final piece is caching: every answer carries a TTL, and resolvers cache aggressively, so although the first lookup of a name takes several round-trips across the world, virtually every subsequent lookup is served from a cache: one short round trip to a nearby resolver, or under a millisecond when your own machine or browser already holds the answer.
1
Ask the root
The resolver asks a root server for the name. The root doesn’t know the domain, but it knows who runs the .com TLD — it returns a referral to the TLD servers.
2
Ask the TLD server
The resolver asks the .com TLD server. It doesn’t hold the record either, but it knows which authoritative servers were delegated the domain — another referral, one step deeper.
3
Ask the authoritative server
The resolver asks the domain’s authoritative server, which actually holds the records and returns the real IP address. The journey is complete.
✓
Cache, then instant repeats
The resolver caches the answer for its TTL and hands the IP back to your device. Look the name up again and the cache answers immediately — no journey needed until the TTL expires.
Tree levels
root · TLD · authoritative
Each step
a referral down
First lookup
several round-trips
Resolver cache hit
one round-trip
OS / browser cache hit
< 1 ms
The code
# Recursive resolution (what your resolver does for you)defresolve(name):
if name in cache and not expired(name):
return cache[name] # instant: served from cache
server = a_root_server # start at the top of the treewhile True:
reply = ask(server, name)
if reply.is_answer:
cache.put(name, reply.ip, ttl=reply.ttl)
return reply.ip # authoritative server answered
server = reply.referral # root → TLD → authoritative
The picture: one lookup, eight messages
The lab’s journey as messages. Only the resolver talks to the tree; your device sends one question and gets one answer. Each server above answers from what it holds: the root and the TLD hold only delegations, so they reply with a referral, and only the authoritative server holds the record. The resolver caches the referrals as well as the answer, each for its own TTL, which is why a later lookup in .com usually skips the root entirely. The address 203.0.113.7 is from the range reserved for documentation.
Worked example: a cold lookup, then the cache
Say the device is 10 ms from its resolver, and the resolver is 20 ms from a root server, 30 ms from a .com server and 40 ms from the domain’s authoritative server. These round-trip times are illustrative. The A record has a TTL of 300 seconds; the domain’s NS records have a longer one.
Step
Who asks whom
Reply
Time so far
1
device → resolver: A? www.vibeengines.com
cache miss, resolver starts walking
0 ms
2
resolver → root
referral: the .com servers
20 ms
3
resolver → .com TLD
referral: the domain’s name servers
50 ms
4
resolver → authoritative
A 203.0.113.7, TTL 300
90 ms
5
resolver → device
answer, now cached at the resolver
100 ms (10 + 20 + 30 + 40)
6
same name, 120 s later
cache hit, 180 s of TTL left
10 ms, one round trip
7
same name, 301 s later
A expired, NS still cached: ask the authoritative only
50 ms (10 + 40)
8
1,000 lookups/s of this name through one resolver
1,000 × 300 s answered per walk
300,000 answers per upstream query
Step 7 is the one the lab skips: an expired answer does not send the resolver back to the root, because the referrals it learned on the way down are still cached under their own TTLs. Step 8 is why the root and TLD tiers survive at all. A popular name costs its authoritative servers one query per resolver per TTL, however many people look it up.
Cost and TTL trade-offs
Here Time is what the user waits, using the round-trip times above, and Space is what the lookup costs upstream.
Case
Time
Space
Why
Cold lookup, nothing cached
4 round trips: 100 ms
3 queries leave the resolver
Only the first lookup of a name pays this; also any lookup after every cached level has expired.
Referrals cached, answer expired
2 round trips: 50 ms
1 query to the authoritative server
The common case for a name with a short TTL.
Resolver cache hit
1 round trip: 10 ms
none
Still a network hop. Nearby public resolvers keep this small but never zero.
OS or browser cache hit
no network
none
The only lookup that is truly instant, and it lasts no longer than the record’s TTL.
TTL 86,400 s (a day)
fastest repeats
1 refresh per resolver per day
A change can take up to a day to reach everyone who cached the old record.
TTL 60 s
more cold-ish lookups
up to 1,440 refreshes per resolver per day
Changes reach everyone within about a minute, at the price of load and latency.
There is no correct TTL, only a choice of what to pay for. Records that rarely change, like NS and MX, sit comfortably at hours or days. Records you may need to move in an incident are worth keeping short, or lowering in advance.
Common mistakes with DNS
Lowering the TTL on migration day
If the record had a TTL of 86,400 s, resolvers that cached it this morning will keep the old address for up to a day, whatever you set now. Lower the TTL at least one old-TTL period before the change, make the change, then raise it again once traffic has moved. DNS changes are never pushed; old answers simply expire.
Believing a resolver cache hit is free
Only a hit in the cache on your own machine, in the operating system or the browser, comes back in under a millisecond. A hit in the recursive resolver still costs one round trip to it, which is the 10 ms in the example above. Measure lookups from where your users are, not from a server sitting next to its resolver.
Querying a name before it exists
“Does not exist” answers are cached too, for a time set by the zone’s SOA record. Look up a hostname before you create it, as a deploy script or health check might, and resolvers can keep answering NXDOMAIN after the record is live. Create records before anything asks for them.
Putting a CNAME at the zone apex
A CNAME cannot sit beside other records for the same name, and the apex (vibeengines.com itself) must carry SOA and NS records. So www can be a CNAME to a hosting provider but the bare domain cannot. DNS providers solve this with ALIAS, ANAME or “CNAME flattening” records, which resolve the target on their side and serve plain A records.
Assuming every client honours the TTL
Long-running processes often resolve once and then hold connections, or cache addresses on their own terms; the JVM’s networkaddress.cache.ttl setting is the classic example. A 60-second TTL does not move a client that resolved at start-up and kept its pool open. Failover plans need connection limits or restarts, not only DNS.
Where this shows up: production and interviews
Load balancing and failover by DNS
Managed DNS services such as Amazon Route 53 can answer the same name differently by health check, by weight or by the user’s location. This is DNS doing routing, and it inherits DNS caching. Failover is only as fast as the TTL and the clients that honour it, so these records are kept short.
CDNs
You point www at the CDN with a CNAME, and the CDN’s own authoritative servers pick an edge close to the resolver asking. The referral chain in this lab gains one more hop, and the CDN gets to choose the answer for each region.
Every Service gets a name like my-svc.my-namespace.svc.cluster.local, answered by the cluster’s DNS. Pods default to ndots:5, so a name with fewer than five dots is tried against each search domain first. An external name like api.example.com can cost several failed lookups before the real one. A trailing dot makes it absolute and skips them.
The “what happens when you type a URL” interview
DNS is step one, and interviewers listen for layers: browser cache, OS cache, then the recursive resolver walking root → TLD → authoritative, all over UDP port 53, with TCP for large answers. Then TTLs and negative caching. There are 13 root server identities, each run on many machines through anycast. Strong answers end by handing the IP to TCP and TLS.
Quick check
1. What does a root server return when asked to resolve www.vibeengines.com?
Root servers don’t hold domain records. They know which servers run each top-level domain, so they return a referral pointing the resolver to the .com TLD servers — the first step down the tree.
2. Who actually holds the real DNS records for a domain?
The authoritative name servers for a domain hold its actual records (A, AAAA, MX, etc.). Root and TLD servers only refer you down the tree; the authoritative server is where the resolution ends with a real answer.
3. Why is the second lookup of the same name almost instant?
Every DNS answer carries a TTL (time-to-live). The recursive resolver caches the answer for that duration, so subsequent lookups cost a single round-trip to the resolver (or nothing at all if your OS or browser cached it too) — no walk down the tree needed until the TTL expires.
FAQ
What is DNS resolution?
Turning a human-readable domain name into the IP address a computer needs to connect. DNS is a distributed hierarchical tree, and a recursive resolver walks it: it asks a root server (which refers it to the TLD server), then the TLD server (which refers it to the authoritative server), which returns the actual address. The resolver caches the answer for its TTL.
What is the difference between a recursive resolver and an authoritative server?
A recursive resolver does the legwork: it chases the chain of referrals (root → TLD → authoritative) until it has the answer, then returns and caches it. An authoritative server is one end of that chain — it holds the real records for a specific domain and gives definitive answers, but doesn’t chase other names. Your device talks to a resolver; the resolver talks to authoritative servers.
What is a DNS TTL and why does it matter?
TTL (time-to-live) says how many seconds a DNS record may be cached before re-fetching. It’s the central DNS trade-off: a long TTL means faster lookups and less load but slow propagation of changes (old answers linger in caches); a short TTL propagates changes fast but increases traffic. Teams often lower TTLs before a planned migration, then raise them after.
What is DNS caching and where does it happen?
DNS caching stores resolved answers so repeat lookups skip the tree walk. It happens in the OS stub resolver, sometimes the browser, and most importantly the recursive resolver (which serves many users and caches popular names heavily). Because of caching, the vast majority of lookups never reach the root or TLD tiers — which would otherwise be overwhelmed. It’s what makes a global lookup feel instant.