Skip to the guide

How DNS works

BeginnerConcept3 pages

DNS turns a name like api.example.com into an IP address. Every request your design serves starts with it, so it's also one of your first tools for steering traffic: to the nearest region, or away from one that's down. Interviewers want to know how a lookup works, and above all how long a DNS change takes to reach users.

A hotel concierge finding a number

You ask the hotel concierge for the number of a restaurant across town. She checks her notebook first. If it isn't there, she calls the main directory, which says "restaurants have their own directory, here's its number". The restaurant directory says "that restaurant manages its own listing, call this number". The restaurant's own line gives her the answer. She writes it in her notebook with a note: "good until Friday". The next guest who asks gets it straight from the notebook.

In DNS terms:

  • the concierge → recursive resolver: does the asking on your behalf, usually run by your internet provider, or a public one like Google's 8.8.8.8 or Cloudflare's 1.1.1.1
  • her notebook → the resolver's cache
  • the main directory → root servers: know who handles each ending (.com, .org, .uk)
  • the restaurant directory, one for each kind of business, or each country → top-level domain (TLD) servers: for .com, know who handles each name under it
  • the restaurant's own line → authoritative name servers: hold your actual records (often a managed service like Amazon Route 53 or Cloudflare)
  • "good until Friday" → TTL (time to live): how many seconds a resolver may keep the answer