DNS
0-day streakReview

Your progress

Level 1

0 XP100 XP to level 2
0day streak
0best streak
0topics started
0cards reviewed
    Review cards

    Progress is stored only in this browser. No account is required.

    Domain Name System (DNS): the 60-second story

    Domain Name System

    New in Delhi, you know a sweet shop’s name, not its address.

    Your cousin asks a directory, an association, then the shop, and notes “good for a week” in his diary. That’s DNS.

    You ask the resolver once. It asks three servers.

    On a miss it walks the tree. Root refers it to .com, .com to your authoritative servers, and they answer with a TTL.

    A cache hit is nearly free. A cold walk isn’t.

    Illustratively, with root and .com cached: a resolver 15 ms away plus your servers 150 ms away ≈ 165 ms before TCP starts. So keep hostnames few.

    Edit a record. When does traffic move?

    Bad: Right away

    Caches keep the old answer until its TTL runs out.

    Good: Up to a TTL later

    Cut the TTL to 60 s one old TTL before a move.

    150 s

    to fail over with a 60 s TTL

    Three failed 30-second checks take up to 90 s. Caches keep the dead address one more TTL. Clients that ignore TTLs take longer.

    DNS flipped to Hyderabad; resolvers followed. Your Java service still calls Mumbai.

    The catch

    The TTL is a request, not a contract. JVMs may cache forever; pools resolve once. Set the JVM’s TTL; cap connection lifetimes.

    DNS picks the region. A load balancer picks the server.

    Latency or failover records send users to a healthy region, in minutes. Inside it, the load balancer routes around a dead server in seconds.

    When DNS is the outage

    1. Dyn 2016: name servers from two independent providers
    2. Long TTLs keep cached answers working
    3. Facebook 2021: never let health checks remove the last capacity
    4. Keep emergency access off your own DNS

    Remember

    Every cache keeps DNS answers for the TTL: fast, cheap and stale. So DNS picks the region; a load balancer picks the server, because DNS failover takes minutes, not seconds.