TL;DR

1. The problem: why do we need DNS?

Computers route packets using IP addresses like 157.240.22.174 or 2a03:2880:f12f:83:face:b00c:0:25de. Humans and apps use names like instagram.com. Something has to translate — and it has to do so for billions of devices, millions of times per second, in a few milliseconds, without one central server that could fail or be overwhelmed.

Names also give system designers a crucial layer of indirection. If the Instagram app had a hard-coded IP address baked into it:

With DNS, the app asks "where is i.instagram.com right now, for me?" and Instagram's name servers can answer differently depending on the user's location, server health and load. DNS is therefore the very first hop in Instagram's architecture diagram and the first lever for global traffic management.

🧠 Analogy DNS is like finding someone's phone number through a chain of directories. You (the app) ask your personal assistant (the recursive resolver). If the assistant doesn't already know, they ask the international directory (root), which says "for .com numbers, ask the .com directory". The .com directory (TLD) says "for instagram.com, ask Instagram's own receptionist". Instagram's receptionist (authoritative server) gives the actual number — maybe a different branch office depending on which city you're calling from. Your assistant writes the number in a notebook (cache) with a "valid until" date (TTL), so next time they answer instantly.

2. The DNS hierarchy

2.1 Anatomy of a name

Read a domain name right to left. The fully qualified name i.instagram.com. has an invisible trailing dot representing the root:

i   .   instagram   .   com   .   (root)
│        │               │        └── root zone: managed by IANA, served by root servers
│        │               └─────────── top-level domain (TLD): .com, run by Verisign
│        └─────────────────────────── second-level domain: instagram.com, owned by Meta
└──────────────────────────────────── subdomain / hostname inside Meta's zone

Each level is responsible only for delegating to the next. The root doesn't know Instagram's IP; it only knows who runs .com. The .com servers don't know it either; they know which name servers are authoritative for instagram.com. A zone is the slice of the namespace one organisation administers, and NS records are the signposts that delegate a sub-zone to other servers.

ROOT TLD Root ( . ) 13 names, 1,000+ sites .com TLD servers .org TLD servers .in country-code TLD instagram.com Meta's authoritative NS cdninstagram.com media / CDN zone wikipedia.org another zone gov.in another zone i.instagram.com (API) scontent-bom1-1… Each level only delegates (NS records) to the next; only the authoritative zone holds the actual IPs.
The DNS namespace is a tree. Root servers delegate to TLD servers, which delegate to each domain's authoritative servers, which hold the final records for hostnames like i.instagram.com.

2.2 The three kinds of servers in the hierarchy

🌳 Root servers

13 logical root server names (a.root-servers.net … m.root-servers.net), run by 12 independent organisations, but replicated via anycast to well over 1,000 physical sites worldwide. They only answer "who runs this TLD?".

🏷️ TLD servers

Serve one top-level domain: generic (.com, .org, .app) or country-code (.in, .uk). They hold NS records for every registered domain under them — hundreds of millions for .com.

📖 Authoritative servers

Hold the actual records for a zone (A, AAAA, CNAME, MX…). Run by the domain owner or a managed DNS provider. For big platforms, they also run the routing logic (GeoDNS, health checks).

You don't talk to these servers directly from your phone. That's the job of a resolver.

3. Resolvers and the full resolution walkthrough

3.1 Stub resolvers vs recursive resolvers

3.2 Full resolution, step by step (cold caches)

 Phone app/OS        Recursive resolver        Root server        .com TLD server     instagram.com auth NS
 (stub resolver)     (ISP / 8.8.8.8)
     |                      |                       |                    |                      |
 (1) | A? i.instagram.com   |                       |                    |                      |
     |--------------------> |  cache miss           |                    |                      |
     |                      | (2) A? i.instagram.com|                    |                      |
     |                      |---------------------> |                    |                      |
     |                      | (3) referral: ".com is served by a.gtld-servers.net …" (NS + glue IPs)|
     |                      | <-------------------- |                    |                      |
     |                      | (4) A? i.instagram.com                     |                      |
     |                      |------------------------------------------>|                      |
     |                      | (5) referral: "instagram.com NS = Meta's name servers" (+ glue)   |
     |                      | <------------------------------------------|                      |
     |                      | (6) A? i.instagram.com                                            |
     |                      |----------------------------------------------------------------->|
     |                      | (7) answer: i.instagram.com A 157.240.x.x  TTL 60                 |
     |                      |     (chosen for THIS resolver's location / client subnet)         |
     |                      | <-----------------------------------------------------------------|
     |                      | (8) cache: root/TLD referrals for days, the A record for 60 s     |
 (9) | <-- 157.240.x.x ---- |                                                                   |
     | OS + app cache it; now open a connection (TCP/TLS or QUIC) to 157.240.x.x            |
  1. The app calls the OS resolver (e.g. getaddrinfo), usually asking for both A (IPv4) and AAAA (IPv6) records. The OS checks its own cache first.
  2. On a miss, the stub sends a UDP packet (port 53) — or an encrypted DoH/DoT query — to the recursive resolver.
  3. The resolver checks its cache. It almost always already knows the root and .com servers (their NS records have TTLs of days), so steps 2–5 are usually skipped. It starts at the closest ancestor it knows.
  4. The root answers with a referral: NS records for .com, plus glue records (the IPs of those name servers, needed to avoid a chicken-and-egg lookup).
  5. The .com TLD server answers with another referral: the NS records for instagram.com (Meta's own name servers) and their glue.
  6. Meta's authoritative server answers with the final record. This is where the intelligence lives: the IP returned depends on where the query appears to come from and which PoPs/regions are healthy.
  7. The resolver caches the answer for its TTL and returns it to the phone; the OS and the app may cache it too.
  8. Only now can the app start the TCP/TLS or QUIC handshake (see Networking basics).

Timing: a fully cold lookup needs up to four network round trips from the resolver (root, TLD, authoritative, plus the phone ⇄ resolver hop) — easily 100–300 ms if any of those servers is far away. A warm lookup answered from the resolver's cache costs one phone ⇄ resolver round trip (5–50 ms; more on a 3G radio), and an OS/app cache hit costs ~0 ms. Because root and TLD answers are cached for days and popular names like i.instagram.com are queried constantly, most lookups at big ISPs are cache hits.

DNS mostly uses UDP because a query and answer each fit in a single packet — no handshake needed, which keeps lookups to one round trip. Responses that are too large (e.g. big DNSSEC answers) fall back to TCP; EDNS(0) extensions allow larger UDP payloads and extra options such as Client Subnet.

4. Caching layers and TTLs

DNS works at planetary scale only because of caching. Every answer carries a TTL (time to live) in seconds, set by the zone owner: "you may reuse this answer for this long without asking again". Caches exist at several layers:

LayerWhoNotes
App / browser cacheChrome's host cache, the app's HTTP library (OkHttp, Cronet)Often caps TTLs at about a minute; some apps pre-resolve hostnames at launch
OS cacheiOS/Android/Windows/macOS resolver, systemd-resolvedShared by all apps on the device
Home router / CPESmall forwarding cache in your Wi-Fi routerOptional; sometimes buggy (ignores TTLs)
Recursive resolverISP, carrier, Google/Cloudflare/Quad9, corporateThe big one — shared by millions of users, so popular names are almost always hot
Negative cacheResolvers"This name does NOT exist" (NXDOMAIN) is cached too, for a duration derived from the zone's SOA record

Each cache counts the TTL down from when it received the answer. If the authoritative TTL is 300 s and the resolver got the answer 200 s ago, it hands your phone the record with TTL 100.

4.1 How much load does caching save?

Assume 500M daily users, each device resolving the API hostname 20×/day (app opens, network changes)
  device-level lookups = 10 billion/day ≈ 116,000 per second
Assume those devices sit behind ~100,000 recursive resolver instances and the TTL is 60 s
  worst case at the authoritative = 100,000 resolvers × 1 query / 60 s ≈ 1,700 QPS
→ resolver caching cuts authoritative load by ~70× even with a short 60 s TTL.
  With TTL = 3600 s it would be ~28 QPS — but changes would take up to an hour to propagate.
⚠️ "DNS propagation" is really cache expiry When people say a DNS change "takes 24 hours to propagate", nothing is being pushed anywhere. The new record is live on the authoritative servers immediately; caches around the world simply keep serving the old answer until their TTL runs out. Some resolvers and clients also ignore or clamp TTLs (e.g. enforce a minimum), and long-lived processes (old Java versions famously cached DNS forever by default) may never re-resolve. Always plan for stragglers.

5. Record types

A zone is a list of resource records: name, TTL, class (almost always IN), type, value. The ones every engineer should know:

TypePurposeExampleNotes
AName → IPv4 addressi.instagram.com. 60 IN A 203.0.113.10Multiple A records = several IPs (client picks one); the core record type
AAAAName → IPv6 addressi.instagram.com. 60 IN AAAA 2001:db8::10"Quad-A". Clients race IPv6 and IPv4 ("Happy Eyeballs") and use whichever connects first
CNAMEAlias: "this name is really that name"www.example.com. 300 IN CNAME example.cdnprovider.net.Resolver follows the chain. A CNAME can't coexist with other records at the same name, so it can't be used at the zone apex (example.com itself) — providers offer ALIAS/ANAME "flattening" instead. Each hop may cost an extra lookup
NSWhich servers are authoritative for a zone (delegation)instagram.com. 172800 IN NS a.ns.example.net.Lives in the parent (TLD) and in the zone itself; long TTLs (often 2 days)
MXMail servers for the domain, with priorityexample.com. 3600 IN MX 10 mx1.example.com.Lower number = preferred. Only used for email
TXTArbitrary textexample.com. 300 IN TXT "v=spf1 include:_spf.example.net -all"Domain ownership verification, email security (SPF, DKIM, DMARC), other policies
SOAStart of Authority: zone metadataexample.com. IN SOA ns1.example.com. dns-admin.example.com. 2026102301 7200 900 1209600 300Primary server, admin contact, serial number (version of the zone), refresh/retry/expire timers for secondaries, and the negative-caching TTL
PTRReverse lookup: IP → name10.113.0.203.in-addr.arpa. PTR edge1.example.com.Used by mail servers, logging, traceroute
SRVService location: host + port + priority/weight_sip._tcp.example.com. SRV 10 60 5060 sip1.example.com.Used in some service-discovery setups (e.g. Kubernetes, Consul)
CAAWhich CAs may issue certificates for the domainexample.com. CAA 0 issue "letsencrypt.org"Security hardening for TLS certificates

Here is a tiny, illustrative zone (documentation IP ranges, not Instagram's real records):

$ORIGIN example-photos.com.
@        3600  IN SOA  ns1.example-photos.com. hostmaster.example-photos.com. (
                       2026102301 ; serial (bump on every change)
                       7200       ; refresh: secondaries check every 2 h
                       900        ; retry
                       1209600    ; expire: secondaries give up after 14 days
                       300 )      ; negative-cache TTL
@        172800 IN NS   ns1.example-photos.com.
@        172800 IN NS   ns2.other-provider.net.     ; second provider = no single point of failure
api        60   IN A    203.0.113.10                ; short TTL: steered dynamically
api        60   IN AAAA 2001:db8::10
www       300   IN CNAME web.example-photos.com.
media     300   IN CNAME photos.cdn-provider.example.  ; hand media off to a CDN
@        3600   IN MX   10 mail.example-photos.com.
@         300   IN TXT  "v=spf1 -all"

Use dig to explore real DNS: dig i.instagram.com A, dig +trace instagram.com (shows the root → TLD → authoritative walk), dig instagram.com NS.

6. DNS as a traffic-steering tool

A simple authoritative server returns the same static records to everyone. A smart authoritative server (sometimes called a Global Server Load Balancer, GSLB) computes the answer per query. This is the first layer of global load balancing in Instagram's architecture (see Load balancing).

Authoritative DNS geo + latency + health checks 📱 User in Mumbai 📱 User in Berlin 📱 User in São Paulo Mumbai PoP Frankfurt PoP São Paulo PoP connects to 203.0.113.10 connects to 198.51.100.20 connects to 192.0.2.30 same question, different answers
GeoDNS: three users ask the same question (A record for the API host) and receive the IP of the PoP nearest to them (illustrative documentation IPs). Health checks remove a PoP from answers if it fails.

6.1 GeoDNS and latency-based routing

The catch: the authoritative server sees the resolver's IP, not the user's. If a user in Chennai uses a public resolver whose nearest instance is in Singapore, a naive GeoDNS might send them to a Singapore PoP. The fix is EDNS Client Subnet (ECS): the resolver forwards a truncated prefix of the client's IP (e.g. a /24) so the authoritative server can geolocate the actual user. (Some privacy-focused resolvers deliberately don't send ECS.) Anycast resolvers with instances in many cities also mitigate the problem.

6.2 Weighted routing

Return different answers in configured proportions: 90% of responses point at the old cluster, 10% at the new one. Uses: canary releases of a new region or load balancer, gradual migrations between data centers or clouds, and balancing between regions of different capacity. Because resolvers cache answers and share them among many users, weights are approximate — one resolver serving 1M users who got the "10%" answer moves a big chunk of traffic at once.

6.3 DNS failover with health checks

The DNS provider continuously health-checks each endpoint (e.g. an HTTPS request to /healthz every 10 s from several vantage points). If a region fails N consecutive checks, it's removed from answers; traffic shifts to the remaining healthy endpoints. Variants: active-passive (return the primary unless it's unhealthy, then the secondary) and active-active (return all healthy endpoints).

worst-case failover time ≈ detection time + TTL + client stickiness
  detection: 3 failed checks × 10 s           = 30 s
  TTL                                          = 60 s
  clients that keep existing connections open  = until those connections fail
  → ~1.5 minutes for most users, longer for stragglers that ignore TTLs

That's why DNS failover is good for region-level disasters but too slow and coarse for individual server failures — those are handled by load balancer health checks in seconds.

Routing policyAnswer depends onUse it forWatch out for
Simple / round-robinNothing — return all IPs (often rotated)Spreading load across a few equal serversNo health awareness; clients may stick to the first IP
GeolocationClient/resolver locationNearest PoP, data residency, localized contentResolver location ≠ user location (use ECS)
Latency-basedMeasured network latencyLowest-latency region for each networkNeeds good measurement data
WeightedConfigured percentagesCanary, migration, capacity balancingCoarse because resolvers aggregate many users
FailoverHealth checksRegion / data-center disaster recoveryBounded by TTL and client caching
Multi-valueHealth — returns several healthy IPsClient-side retry across endpointsClients must actually try alternatives

7. Anycast DNS

Anycast means announcing the same IP address from many locations via BGP. Internet routing then delivers each packet to the "closest" location in network terms. (Contrast with unicast, where one IP = one machine.) DNS is the perfect anycast workload: a query and its answer are each a single UDP packet, so there is no long-lived connection that could break if routing shifts mid-conversation.

GeoDNS and anycast are often combined: anycast gets the DNS query to a nearby DNS server, and GeoDNS logic in that server picks a nearby PoP for the actual traffic. Anycast is also used directly for HTTP edges and L4 load balancers — see Load balancing and CDN.

⚠️ The flip side of anycast Anycast DNS servers usually stop announcing their prefix when they detect they are unhealthy — sensible for one bad site. But if every site decides it's unhealthy at the same time, the whole service vanishes from the internet. That is exactly what happened to Meta in October 2021 (section 9.2).

8. TTL trade-offs

Short TTL (30–300 s)Long TTL (1 h – 2 days)
Failover / change speedFast — minutesSlow — hours
Traffic steering precisionCan react to load and health continuouslyCoarse, static
Query volume on authoritative serversHighLow
User latencyMore cache misses → more lookups (each 10–100+ ms)Almost always cached
Resilience if your DNS is downPoor — caches empty within minutesGood — cached answers keep working for hours
Typical useDynamically steered endpoints: API and CDN hostnames, GSLB recordsNS and glue records, MX, static hosts, TXT verification

Practical rules:

9. DNS as a single point of failure

Every request to Instagram starts with DNS. If clients can't resolve the hostname, it doesn't matter that every server, database and cache is perfectly healthy — to users, the service is down. And because DNS outages affect every hostname in a zone at once, they tend to be total rather than partial. Caching softens the blow (answers already cached keep working until their TTL expires), but with short TTLs the grace period is minutes.

9.1 Case study: the 2016 Dyn DDoS

On 21 October 2016, Dyn — a major managed DNS provider serving as the authoritative DNS for many large websites — was hit by a series of massive distributed denial-of-service attacks. The traffic came from the Mirai botnet: a large army of compromised Internet-of-Things devices (cameras, DVRs, home routers with default passwords) flooding Dyn's servers with DNS queries.

💡 Lessons from Dyn
  1. Use multiple, independent authoritative DNS providers (or your own plus a provider) with records kept in sync — the NS set is your redundancy.
  2. Over-provision and anycast DNS infrastructure so attacks are spread out and absorbed.
  3. Don't make every TTL tiny: longer TTLs on stable records let caches carry you through a DNS outage.
  4. Your availability includes your vendors' availability — DNS, CDN and certificate providers are part of your critical path.

9.2 Case study: the October 2021 Facebook / Instagram / WhatsApp outage

On 4 October 2021, Facebook, Instagram, WhatsApp and Messenger disappeared from the internet for roughly six hours — one of the largest outages in internet history. Meta's public post-mortem explained the chain of events:

 1. Routine maintenance: an engineer runs a command intended to ASSESS global backbone capacity.
        │  a bug in the audit tool that should have blocked it lets it through
        ▼
 2. The command takes down ALL connections in Meta's backbone network
    → data centers are disconnected from each other and from the edge PoPs.
        ▼
 3. Meta's authoritative DNS servers (at the edge) run a safety check:
    "If I can't reach the data centers, I'm unhealthy → stop advertising my anycast IPs via BGP."
    Every DNS site reaches the same conclusion at the same time.
        ▼
 4. BGP withdrawal: the internet's routers forget how to reach Meta's DNS server IP prefixes.
    The DNS servers are RUNNING — but unreachable.
        ▼
 5. Resolvers worldwide: "A? i.instagram.com" → no route to the name servers → SERVFAIL.
    Cached answers expire within minutes; apps and users RETRY aggressively
    → public resolvers see a big surge in queries for Meta's domains.
        ▼
 6. Internal tools that depended on the same network/DNS are also down;
    engineers must get PHYSICAL access to data-center hardware (behind strict security) to fix it.
        ▼
 7. Backbone restored → BGP routes re-announced → DNS reachable → traffic returns.
    Load is ramped back carefully: suddenly restoring all traffic risks power surges and cache stampedes.
Bad commandbackbone down
→
DNS health check failsat every site
→
BGP withdrawalno route to NS
→
SERVFAIL everywhereapps "offline"

Why this case study is so instructive for system design:

10. DNS security and privacy

10.1 Attacks

10.2 Defences

TechnologyWhat it protectsHowLimits
DNSSECAuthenticity & integrity of answersZones are cryptographically signed; resolvers validate a chain of trust from the rootNo privacy; operational complexity; partial adoption
DNS over TLS (DoT)Privacy & integrity between stub and resolverDNS inside TLS on port 853Dedicated port is easy to block/identify
DNS over HTTPS (DoH)Privacy & integrity between stub and resolverDNS messages sent as HTTPS requests on port 443 (looks like normal web traffic); supported by major browsers and OSesCentralises queries at a few big resolvers; bypasses enterprise DNS controls; resolver still sees queries
DNS over QUIC (DoQ)Same as DoT, lower latencyDNS over QUIC streamsNewer, less deployed
Registrar lock, MFA, CAA recordsDomain hijacking, rogue certificatesOrganisational controlsProcess discipline required

For a mobile app, DoH has a practical bonus: the app (or OS) can resolve names over the same HTTPS stack it already uses, which avoids broken or hijacking ISP resolvers. Note that DoH protects the hop to the resolver — the TLS SNI field and the destination IP can still reveal which site you're connecting to (Encrypted Client Hello is the emerging fix). See also Security.

11. How Instagram uses DNS

Instagram's DNS has two jobs: tell clients where to connect, and steer them to the right nearby place — for two very different kinds of traffic.

Hostname (publicly observable)PurposeWhere DNS points it
i.instagram.comMobile app API (feed, likes, uploads, etc.)A nearby Meta edge PoP running L4 + L7 (Proxygen) load balancers, which forward to a data-center region
www.instagram.comWeb appSimilar edge infrastructure as the API
scontent-xxx#-#.cdninstagram.com (and *.fbcdn.net)Photos, video segments, thumbnailsA specific CDN cache cluster — the hostname itself often encodes the location, e.g. an airport code like bom (Mumbai)
Real-time / chat endpointsPersistent DM/notification connectionsEdge endpoints that terminate long-lived connections (see Direct messaging)

11.1 Why separate hostnames for API and media?

11.2 Steering users to nearby PoPs and regions

  1. The app asks for i.instagram.com. The query reaches one of Meta's anycast authoritative DNS servers — a nearby one, thanks to anycast.
  2. That server looks up the resolver's network (and the client subnet via ECS, if provided) in a mapping computed centrally from latency measurements, PoP capacity and health. Meta engineers have publicly described such a system (named Cartographer) that computes which edge PoP each client network should use and pushes the map to the DNS servers.
  3. The answer — the VIP (virtual IP) of the best nearby PoP — comes back with a short TTL, so the mapping can change quickly when a PoP is overloaded, drained for maintenance, or fails.
  4. The app connects to that PoP. From there, Meta's own L4/L7 load balancers and backbone take over (see Load balancing).
  5. The feed response contains media URLs on CDN hostnames, which the app resolves the same way — landing on a nearby cache. See CDN.
📸 Instagram specifics Meta runs its own authoritative DNS for its domains (the 2021 outage revealed that its name servers are deployed at its edge sites and anycast-announced via BGP). DNS is the first stage of Meta's global traffic management: it decides which of dozens of edge PoPs (plus caches embedded in ISPs) a user reaches. The mobile apps further reduce DNS cost by caching results and keeping long-lived connections, so on a typical day most requests don't need a fresh DNS lookup at all. The 2021 outage also showed the downside of this tight integration: when DNS became unreachable, all of Meta's apps went down together.

Rough numbers

Assume 500M DAU, 20 lookups/device/day for the API host and ~5 distinct CDN hostnames
  device lookups ≈ 500M × 20 × (1 + 5) = 60 billion/day ≈ 700K/s at the device level
  most are answered by OS or resolver caches;
  authoritative QPS ≈ (number of active resolvers × hostnames) / TTL
                    ≈ (200,000 × 6) / 60 s ≈ 20,000 QPS — modest for an anycast fleet.
  A cache miss adds ~20–150 ms to the first request; with a 60 s TTL and long-lived
  connections, that cost is paid on only a small fraction of requests.

12. Trade-offs & common pitfalls

✅ What DNS gives you

  • Indirection: move, add or remove servers without changing clients
  • Cheap global traffic steering (geo, latency, weights, failover)
  • Massive scale through hierarchical delegation and caching
  • Anycast makes lookups fast and DDoS-resistant

⚠️ Limitations

  • Changes are only as fast as the TTL (and stragglers ignore it)
  • Coarse: steers resolvers, not individual users or requests
  • Adds latency to the first request on a cache miss
  • A critical dependency: a DNS outage = total outage
  • Plain DNS is unauthenticated and unencrypted

Common pitfalls

13. Real-world technologies

Product / toolTypeWhen to use it
Amazon Route 53Managed authoritative DNS with geo, latency, weighted, failover and health checksAWS-hosted systems needing GSLB-style routing
Cloudflare DNS, NS1, Akamai Edge DNS, UltraDNSAnycast managed authoritative DNS, traffic steering, DDoS protectionHigh-availability public domains; often used in pairs for redundancy
Google Cloud DNS, Azure DNS / Traffic ManagerCloud-native authoritative DNS (+ traffic management)Systems on those clouds
BIND, PowerDNS, Knot, NSDSelf-hosted authoritative (and recursive) DNS serversRunning your own DNS at scale (as Meta does with in-house systems)
Unbound, Knot Resolver, dnsmasqRecursive / caching resolversCorporate or data-center internal resolution
Google Public DNS (8.8.8.8), Cloudflare (1.1.1.1), Quad9 (9.9.9.9)Public anycast recursive resolvers with DoH/DoTEnd users; fallback resolvers in apps
CoreDNS, Consul DNSDNS-based service discovery inside clustersKubernetes / microservices (see Microservices)
dig, nslookup, dig +traceDebugging toolsInspecting records, TTLs and delegation paths

14. Interview corner

What happens, step by step, when the app resolves i.instagram.com for the first time?

The OS stub resolver checks its cache, then asks the configured recursive resolver (ISP or public) over UDP 53 or DoH. The resolver checks its cache; on a miss it asks a root server (usually skipped because the .com referral is cached), gets a referral to the .com TLD servers, asks them and gets a referral (NS + glue) to Meta's authoritative name servers, then asks those. Meta's anycast authoritative server picks a nearby healthy edge PoP for that resolver/client subnet and returns its A/AAAA record with a short TTL. The resolver caches every answer for its TTL and returns the IP; the OS and app cache it; the app then opens a QUIC or TCP+TLS connection.

How would you use DNS to route users to the nearest data center, and what are the limitations?

Use GeoDNS or latency-based routing at the authoritative layer (a GSLB): map the resolver/client subnet to the best region based on geography or measured latency, filtered by health checks and capacity, and return that region's VIP with a short TTL. Limitations: the authoritative sees the resolver, not the user (mitigated by EDNS Client Subnet); changes are bounded by TTL and resolvers/clients that ignore it; granularity is per resolver, not per user; and it can't react to per-request conditions. Inside the region, L4/L7 load balancers do fine-grained balancing; anycast can complement DNS for faster failover.

What TTL would you pick for the API hostname, and why?

Short — around 30–300 s (e.g. 60 s) — because we steer it dynamically and want region failover within minutes. That raises authoritative query volume, but resolver caching aggregates millions of users, so the load is modest for an anycast fleet. NS records and static records get long TTLs (hours to days) for resilience. Before a planned migration, lower TTLs in advance. And because short TTLs increase dependence on DNS availability, use multiple anycast sites and ideally redundant providers.

Explain the October 2021 Facebook outage. What would you change in the design?

A maintenance command meant to assess backbone capacity accidentally took down Meta's entire backbone; an audit tool that should have blocked it had a bug. Meta's edge DNS servers, unable to reach the data centers, marked themselves unhealthy and withdrew their BGP anycast announcements — all of them at once — so the name servers became unreachable and every Meta domain failed to resolve worldwide for about six hours. Internal tools were affected too, requiring on-site access. Design changes: health-check logic that never withdraws all sites simultaneously (fail open / keep a minimum set announced); stronger change safety (staged network changes, independent verification, smaller blast radius); out-of-band management networks independent of production DNS/backbone; possibly a secondary DNS presence; and client retry backoff to avoid query storms.

Anycast vs GeoDNS — how do they differ and when would you use each?

GeoDNS returns different IPs to different resolvers; routing decisions are made by your DNS logic and are bounded by TTLs. Anycast advertises the same IP from many sites and lets BGP deliver packets to the nearest one; failover happens as fast as BGP converges (seconds to minutes) with no TTLs, and DDoS is naturally spread. Anycast suits stateless, short exchanges (DNS itself) and L4 edges with connection-aware LBs; GeoDNS gives explicit, policy-driven control (capacity, residency, weights). Large platforms combine them: anycast DNS servers running GeoDNS logic.

Why does Instagram serve media from a different domain than its API?

Separate hostnames let DNS route media to CDN cache clusters and API calls to proxy/edge fleets with different policies; a separate registrable domain (cdninstagram.com) keeps login cookies off millions of image requests and isolates user-uploaded content from the main site's security origin; and it separates failure and scaling domains. Media URLs can even encode a specific cache cluster to maximise hit ratio.

How do you make DNS not be a single point of failure?

Redundancy at every layer: multiple authoritative name servers on separate networks, anycast across many sites, ideally two independent providers with synchronised zones; sensible TTLs so caches carry you through short outages; DDoS capacity and rate limiting; health-check logic that can't take everything down at once; registrar locks and MFA; monitoring of resolution from many vantage points; and clients that cache last-known-good answers and back off on failure.

15. Check your understanding

A resolver received an A record with TTL 300 s two minutes ago. A phone now asks it. What TTL does the phone see, and when will the resolver next contact the authoritative server for this name?

The phone sees TTL ≈ 180 s (300 − 120). The resolver re-queries the authoritative server only after those 180 s expire and someone asks again.

You switch a hostname's A record to a new data center. The old TTL was 86,400 s. What's the worst case before all well-behaved resolvers use the new IP, and how should you have done it?

Up to 24 hours. Better: at least a day before the move, lower the TTL to ~60 s; once the old 24 h TTL has expired everywhere, switch the record (most traffic moves within a minute or two), keep the old site serving for stragglers, then raise the TTL again.

Which record type would you use for each: (a) point photos.example.com at a CDN's hostname, (b) prove domain ownership to a vendor, (c) give the IPv6 address of the API, (d) delegate eu.example.com to a different set of name servers?

(a) CNAME, (b) TXT, (c) AAAA, (d) NS records for eu.example.com in the parent zone (plus glue A/AAAA records if the name servers are inside that subdomain).

A user in Chennai using a public resolver gets sent to a Singapore PoP instead of the Chennai one. Why might that happen and what fixes it?

The authoritative GeoDNS only sees the resolver's IP, and the resolver instance answering the user may be located (or geolocated) in Singapore. Fixes: EDNS Client Subnet so the authoritative sees the user's prefix; resolvers with anycast instances in India; latency-based mapping built from real-user measurements; or anycast for the PoP addresses themselves.

Health checks run every 10 s, a region is removed after 3 failures, and the record TTL is 60 s. Roughly how long until most users move off a dead region?

Detection ≈ 3 × 10 = 30 s, plus up to 60 s of cached answers ≈ ~90 seconds for most users — longer for clients that ignore TTLs or keep existing connections to the dead region until they time out.

In October 2021, were Meta's DNS servers down? Explain precisely what failed.

Mostly no — they were running but unreachable. After the backbone failure, they withdrew their BGP route advertisements (because they couldn't reach the data centers), so the internet had no route to their IP prefixes. Resolvers couldn't reach any authoritative server for Meta's domains and returned SERVFAIL, so the apps couldn't resolve any hostname.

DNSSEC or DoH — which one stops your ISP from seeing which sites you look up? Which one stops a forged answer from being accepted?

DoH (or DoT/DoQ) encrypts the query between your device and the resolver, hiding it from the ISP (though the resolver still sees it). DNSSEC signs records so a validating resolver can reject forged answers — but it doesn't encrypt anything. They solve different problems and can be used together.

🎯 Key takeaways

Related lessons