LogoMasst Docs

DNS

Understanding the Domain Name System and its role in distributed systems.

What is DNS?

DNS (Domain Name System) is the phonebook of the internet. It translates human-readable domain names (like google.com) into IP addresses (like 142.250.185.78) that computers use to communicate.


How DNS Works

User types: www.example.com


        ┌───────────────┐
        │ DNS Resolver  │ (ISP or public like 8.8.8.8)
        └───────┬───────┘
                │ Cache miss

        ┌───────────────┐
        │  Root Server  │ Returns: .com nameserver
        └───────┬───────┘


        ┌───────────────┐
        │ TLD Server    │ Returns: example.com nameserver
        │    (.com)     │
        └───────┬───────┘


        ┌───────────────┐
        │ Authoritative │ Returns: 93.184.216.34
        │    Server     │
        └───────────────┘

DNS Record Types

RecordPurposeExample
AMaps domain to IPv4example.com → 93.184.216.34
AAAAMaps domain to IPv6example.com → 2001:db8::1
CNAMEAlias to another domainwww.example.com → example.com
MXMail serverexample.com → mail.example.com
TXTText data (verification, SPF)"v=spf1 include:_spf.google.com"
NSNameserver delegationexample.com → ns1.example.com

DNS in System Design

Load Distribution

DNS can distribute traffic across multiple servers using Round-Robin:

example.com
    ├──► 192.168.1.1 (Server A)
    ├──► 192.168.1.2 (Server B)
    └──► 192.168.1.3 (Server C)

Geographic Routing

Route users to nearest datacenter based on location.

TTL (Time To Live)

  • Low TTL (60s): Quick changes, more DNS queries
  • High TTL (86400s): Fewer queries, slower propagation

Interview Tips

  • Know the resolution process: Root → TLD → Authoritative
  • Understand record types: A, AAAA, CNAME, MX
  • TTL trade-offs: Low for flexibility, high for performance
  • DNS for load balancing: Round-robin, geographic routing