System Design Academy

Saving…

Lesson 4 of 10 in Module 10 of 54 lessons complete

DNS

Module 1, lesson 4Concept10 min

Definition

DNS

In plain English
DNS is the internet's directory that turns human-friendly names into IP addresses.
Think of it like
It is like your phone's contacts list, where you tap a name and the phone dials the number.

Domain name

In plain English
A domain name is the human-readable name of a site, such as tickets.example.com.
Think of it like
It is like a shop's name on its sign rather than its map coordinates.

Why it exists

You move your service to a new machine, and its IP address changes. Requiring every user to remember the new number would break access. A stable name lets you update the destination in one directory.

Saving lookup answers nearby reduces repeated work. Old saved answers delay address changes.

How it works

Resolver

In plain English
A resolver is the server that does the lookup work on your device’s behalf.
Think of it like
It is like a librarian who finds the book so you do not search every shelf.

TTL

In plain English
A TTL is how many seconds a DNS answer may be reused before it must be looked up again.
Think of it like
It is like the best-before date on a carton of milk.
  1. Check nearby copies

    The browser and operating system check saved answers first.

  2. Ask the recursive resolver

    The resolver returns a saved answer or looks up a fresh one.

  3. Follow referrals

    The root directs the resolver to .com servers. They direct it to servers holding the domain's records.

  4. Save and connect

    The resolver saves the address for its TTL and returns it. The client then connects.

The browser asks the resolver for tickets.example.com. The resolver follows root and .com referrals to the authoritative server, then returns 203.0.113.7 with TTL 300.

A lookup without saved answers follows referrals to the authoritative server.

The browser asks the resolver for tickets.example.com. The resolver follows root and .com referrals to the authoritative server, then returns 203.0.113.7 with TTL 300.

RecordPoints to
AAn IPv4 address
AAAAAn IPv6 address
CNAMEAnother hostname
MXMail server hostname and priority
TXTText used for verification or mail policy

Examples

Move a podcast host

Your podcast host is moving its audio service to a new machine.

  1. Prepare a day ahead

    Lower TTL from 86,400 seconds to 60; allow the old TTL to expire before moving.

  2. Switch

    Change the A record while keeping the old host working during the overlap.

  3. Settle

    After verifying the move, raise the TTL again.

Plan the TTL change before switching the address.
Text
; Before preparation
audio.example.com. 86400 IN A 203.0.113.7
; During migration, after the old TTL has elapsed
audio.example.com. 60 IN A 203.0.113.8
; After verification
audio.example.com. 86400 IN A 203.0.113.8

The insight

Plan TTL before a change, not during it.

Trade-offs

Pros

  • Long TTLs reduce lookups.
  • Saved answers reduce startup delay.
  • Valid cached answers can outlast brief DNS outages.

Cons

  • Address changes reach callers slowly.
  • Failover waits for old answers to expire.

Use when

  • Addresses rarely change.
  • Lookup cost matters more than rapid redirection.

Avoid when

  • A migration is approaching.
  • Fast DNS-based failover is required.

Quick check

You changed your site's IP 5 minutes ago, but some users still reach the old server. Most likely reason?
Which record points shop.example.com at another hostname?

Takeaways

  • DNS maps names to IPs.
  • Answers are cached for their TTL.
  • Names let you move servers without telling users.

Try the quick check above whenever you feel ready.

Previous: IP Addresses, Ports & Packets