Back to course
    article~27 min readSystem Design Foundations

    DNS Deep Dive

    Trace how names resolve into the infrastructure behind every request.

    DNS Deep Dive — Beginner Friendly System Design Guide

    What Happens When You Type Google.com?

    When you type:

    google.com
    

    your browser does NOT understand:

    • google.com
    • swiggy.com
    • youtube.com

    Computers communicate using:

    IP Addresses
    

    like:

    142.250.xxx.xxx
    

    So before opening website, internet must first answer:

    "What is the IP address of this domain?"
    

    This entire process is called:

    DNS Resolution
    

    What Is DNS?

    DNS stands for:

    Domain Name System
    

    It works like:

    • internet phonebook
    • contact list for websites

    Real-Life Analogy

    Imagine you want to call friend.

    You search:

    Rahul
    

    inside contacts.

    Phone internally uses:

    • actual phone number

    Similarly:

    • humans use domain names
    • computers use IP addresses

    DNS connects both worlds.


    Why DNS Exists

    Without DNS, users would need to remember:

    172.217.160.142
    

    instead of:

    google.com
    

    Impossible at internet scale.


    Real Example — Opening Swiggy

    Suppose you open:

    swiggy.com
    

    Before page loads:

    • browser performs DNS lookup

    to find Swiggy server IP.


    High-Level DNS Flow

    User Types swiggy.com
            │
            ▼
    Browser Checks Local Cache
            │
            ▼
    DNS Resolver Asked
            │
            ▼
    Root DNS Server
            │
            ▼
    TLD DNS Server (.com)
            │
            ▼
    Authoritative DNS Server
            │
            ▼
    Returns IP Address
            │
            ▼
    Browser Connects To Server
    

    Step 1 — Browser Cache Check

    Browser first checks:

    "Do I already know this IP?"
    

    If recently visited:

    • cached result used
    • much faster

    Browser Cache Flow

    User Opens Website
           │
           ▼
    Browser Cache Check
       │             │
    Found          Not Found
       │              │
       ▼              ▼
    Use Cached    Ask DNS Server
    IP
    

    Step 2 — Operating System Cache

    If browser doesn't know:

    • OS checks its own DNS cache

    Modern operating systems cache DNS responses.


    Step 3 — DNS Resolver

    If cache miss happens:

    request goes to:

    DNS Resolver
    

    Usually provided by:

    • ISP
    • Google DNS
    • Cloudflare DNS

    Popular DNS Providers

    ProviderDNS IP
    Google DNS8.8.8.8
    Cloudflare1.1.1.1
    OpenDNS208.67.222.222

    Step 4 — Root DNS Server

    Resolver asks:

    "Who handles .com domains?"
    

    Root server responds:

    • ask .com TLD server

    DNS Hierarchy

    Root DNS
       │
       ▼
    TLD DNS (.com)
       │
       ▼
    Authoritative DNS
       │
       ▼
    Website IP Returned
    

    Step 5 — TLD Server

    TLD means:

    Top Level Domain
    

    Examples:

    • .com
    • .in
    • .org

    TLD server says:

    "swiggy.com is managed by this DNS server"
    

    Step 6 — Authoritative DNS Server

    Final DNS server contains actual records.

    Example:

    swiggy.com → 13.xxx.xxx.xxx
    

    IP returned to browser.


    Step 7 — Browser Connects To Server

    Now browser knows:

    • exact server IP

    Browser can:

    • establish TCP connection
    • send HTTP request

    Complete Real DNS Resolution Flow

    User Types swiggy.com
            │
            ▼
    Browser Cache
            │
            ▼
    OS Cache
            │
            ▼
    DNS Resolver
            │
            ▼
    Root DNS Server
            │
            ▼
    .com TLD Server
            │
            ▼
    Authoritative DNS Server
            │
            ▼
    Returns IP Address
            │
            ▼
    Browser Connects To Swiggy Server
    

    What Is An IP Address?

    IP address identifies device/server on internet.

    Like:

    • home address for computers

    Example

    142.250.190.46
    

    IPv4 vs IPv6


    IPv4

    Traditional format:

    192.168.1.1
    

    Limited addresses.


    IPv6

    New format:

    2409:40f0:1021:...
    

    Supports huge internet growth.


    DNS Records

    DNS stores multiple record types.


    Common DNS Records

    RecordPurpose
    ADomain → IPv4
    AAAADomain → IPv6
    CNAMEAlias
    MXMail server
    TXTVerification/security

    Example DNS Record

    swiggy.com → 13.xxx.xxx.xxx
    

    What Is TTL?

    TTL means:

    Time To Live
    

    It defines:

    • how long DNS result stays cached

    Example

    TTL = 300 seconds
    

    DNS cached for:

    • 5 minutes

    Why Caching Matters

    Without caching:

    • every website visit requires full DNS lookup

    Internet would become slower.

    Caching improves:

    • speed
    • scalability
    • latency

    DNS Cache Flow

    First Request
         │
         ▼
    DNS Lookup Performed
         │
         ▼
    Result Cached
         │
         ▼
    Future Requests Faster
    

    Real Example — Hotstar During IPL

    During IPL:

    • crores of users open Hotstar simultaneously

    DNS helps:

    • distribute traffic
    • route users
    • reduce latency

    Without DNS scalability:

    • platform may fail.

    DNS And Load Balancing

    DNS can distribute traffic across regions.


    Example

    Indian users:

    • routed to Mumbai servers

    US users:

    • routed to US servers

    Geo Routing Flow

    User Location
          │
          ▼
    DNS Detects Region
          │
     ┌────┼────┐
     ▼         ▼
    India     USA
    Server    Server
    

    DNS And CDN

    CDNs heavily depend on DNS.

    DNS routes users to:

    • nearest CDN edge server

    CDN Routing Example

    Jaipur User
         │
         ▼
    DNS Resolution
         │
         ▼
    Nearest CDN Server Selected
    

    Why DNS Sometimes Feels Slow

    Slow DNS can delay:

    • page loading
    • API requests
    • app startup

    Possible DNS Problems

    ProblemImpact
    Slow resolverHigh latency
    DNS outageWebsite inaccessible
    Cache missExtra lookup time
    Wrong recordsTraffic routing failure

    Real Example — Internet Outages

    Large outages sometimes happen because:

    • DNS misconfiguration
    • DNS provider failure

    Even if servers are healthy:

    • users cannot find them

    DNS And Security

    DNS attacks are common.


    Examples

    AttackMeaning
    DNS SpoofingFake DNS response
    DDoSOverload DNS servers
    Cache PoisoningCorrupt cached records

    Why Cloudflare Became Popular

    Cloudflare provides:

    • fast DNS
    • DDoS protection
    • CDN
    • security

    DNS Over UDP

    Most DNS requests use:

    UDP
    

    because:

    • lightweight
    • faster
    • tiny packets

    DNS Protocol Flow

    Browser
       │
       ▼
    DNS Request (UDP)
       │
       ▼
    DNS Resolver
       │
       ▼
    IP Address Returned
    

    Real Internet Journey Example

    User Opens Swiggy
            │
            ▼
    DNS Resolves Domain
            │
            ▼
    Browser Gets IP Address
            │
            ▼
    TCP Connection Established
            │
            ▼
    HTTPS Handshake
            │
            ▼
    HTTP Request Sent
            │
            ▼
    Swiggy Server Responds
    

    Common Beginner Misconceptions


    "DNS Is Just Small Internet Feature"

    No.

    Without DNS:

    • internet usability collapses

    "DNS Lookup Happens Every Time"

    Not always.

    Caching avoids repeated lookups.


    "Fast Internet Means Fast DNS"

    Not necessarily.

    Slow DNS can make:

    • fast internet feel slow

    Final Mental Model

    DNS =
    Internet's phonebook
    that converts domain names into IP addresses
    

    Final Architecture Diagram

    User
      │
      ▼
    Browser
      │
      ▼
    DNS Resolver
      │
      ▼
    Root DNS
      │
      ▼
    TLD DNS
      │
      ▼
    Authoritative DNS
      │
      ▼
    IP Address Returned
      │
      ▼
    Website Server
    

    One-Line Interview Definition

    DNS (Domain Name System) is a distributed hierarchical system that translates human-readable domain names into IP addresses so clients can locate servers across the internet.

    Module context

    How the internet actually works, the client-server model, databases, and APIs. The building blocks every architect needs before anything else.

    Mark this lesson complete when you finish reviewing it.