Skip to main content

Command Palette

Search for a command to run...

DNS as a System (Part 1)

Updated
9 min readView as Markdown

DNS: A Distributed System

Introduction

Every time you open a browser and type a URL, a remarkably complex yet invisible system springs into action — translating a human-readable domain name into a machine-readable IP address in milliseconds. That system is the Domain Name System (DNS).

What makes DNS extraordinary is not just what it does, but how it was designed. Built in the 1980s, DNS continues to support the exponential growth of the internet decades later. The architects of DNS anticipated future expansion by implementing a distributed system from day one — and that architectural decision is what we'll explore in depth here.

By the end of this article, you'll understand:

✅ What a distributed system is and why DNS needed to be one
✅ The core components of the DNS architecture
✅ How DNS achieves speed, reliability, and scalability
✅ The hierarchy of DNS servers and their roles
✅ How a DNS query flows from start to finish
✅ Caching, TTL, and redundancy in DNS
✅ Why this design matters for modern engineers

What Is a System?

Before diving into DNS specifically, let's establish a foundation.

A system is a collection of interconnected elements working together to achieve a common goal.

Much like an ecosystem — where living and non-living components interact to maintain environmental balance — a technical system comprises interconnected components that collaborate toward a shared objective.

A distributed system extends this by spreading responsibilities, data, and processing across multiple nodes and geographic locations, so:

  • No single machine is overwhelmed

  • Failure of one component does not bring the whole system down

  • The system can scale by adding more nodes

DNS is one of the most successful distributed systems ever built.

Why DNS Had to Be Distributed

The Problem With Centralization

In the early days of the internet (ARPANET), a single file called HOSTS.TXT maintained by Stanford Research Institute contained every hostname-to-IP mapping. Every computer on the network downloaded this file periodically.

# Early ARPANET HOSTS.TXT (simplified)
10.0.0.1    HOSTS.SRI
10.0.0.2    MIT-AI
10.0.0.3    BBN-NET
...

This worked when there were hundreds of hosts. It broke down fast.

Problems with centralization:

Centralized Approach — Failure Points
────────────────────────────────────────
Single Point of Failure:
├─ If the central server goes down → entire internet breaks
├─ No fallback, no redundancy
└─ One server for billions of queries per day = impossible

Performance Bottleneck:
├─ All queries routed to one location
├─ Geographic latency issues
└─ Server cannot physically handle global traffic

Scalability Ceiling:
├─ Billions of domains today (and growing)
├─ No single database can hold and serve all records at scale
└─ Update frequency would be unmanageable centrally

The Solution: Distribute Everything

DNS solved this by distributing:

What Was Distributed How
Data Split across millions of name servers
Responsibility Delegated hierarchically (Root → TLD → Domain)
Query resolution Handled by recursive resolvers close to users
Redundancy Multiple servers for every zone
Geographic coverage Servers deployed globally

The Three Pillars of DNS Design

The distributed architecture of DNS is built to achieve three non-negotiable goals:

┌─────────────────────────────────────────┐
│         DNS Design Goals                │
│                                         │
│   ⚡ FAST        Millisecond resolution │
│   🔒 RELIABLE    Fault tolerant         │
│   📈 SCALABLE    Grows with internet    │
└─────────────────────────────────────────┘

⚡ Speed

DNS must be fast because it is a prerequisite for every internet interaction. A slow DNS creates a bottleneck before a single byte of actual content is delivered. DNS achieves speed through:

  • Caching at multiple levels

  • Geographically distributed resolvers

  • Hierarchical delegation (queries go to the nearest authoritative source)

🔒 Reliability

Reliability is achieved through fault tolerance — the system continues functioning even when individual components fail. Imagine having to memorize IP addresses for every website if DNS became unavailable. Reliability is built in via:

  • Multiple root servers (13 root server clusters, each with hundreds of instances)

  • Redundant name servers per zone

  • Distributed resolvers operated by ISPs and public providers

📈 Scalability

The internet has grown from a few hundred hosts to over 1.1 billion websites. DNS accommodates this through:

  • Hierarchical delegation — each zone owner manages their own records

  • Any organization can add name servers without affecting the global system

  • Records and servers can be added continuously without restructuring

The Two Core DNS Components

DNS can be simplified into two primary functional roles:

1. Recursive Resolver

The recursive resolver (also called a recursive nameserver or full-service resolver) is the workhorse of the DNS query process.

Recursive Resolver — Responsibilities
──────────────────────────────────────
├─ Receives DNS queries from client devices
├─ Checks local cache for existing answers
├─ If cache miss → queries root servers
├─ Follows referrals down the hierarchy
├─ Returns final answer to the client
└─ Caches results with TTL for future queries

The Detective Analogy:

Think of the recursive resolver as a seasoned detective:

  • Has a notebook of previous cases (cache)

  • Knows which specialists to contact (root → TLD → authoritative)

  • Does all the legwork so the client doesn't have to

  • Delivers the final answer efficiently

Common recursive resolvers used today:

Provider IP Address Notes
Google Public DNS 8.8.8.8 / 8.8.4.4 Most widely used
Cloudflare DNS 1.1.1.1 / 1.0.0.1 Privacy-focused, fastest
OpenDNS 208.67.222.222 Filtering features
ISP Resolver Varies Default for most users

2. Name Server

The name server stores the actual DNS records — the mappings between domain names and their corresponding data (IP addresses, mail servers, etc.).

Name Server Types
──────────────────────────────────────────────
Root Name Servers
├─ 13 logical root server addresses (A–M)
├─ Hundreds of physical instances via Anycast
├─ Know the location of all TLD name servers
└─ Operated by ICANN, VeriSign, universities, etc.

TLD Name Servers
├─ One set per TLD (.com, .org, .net, etc.)
├─ Know the location of all registered domain name servers
└─ Operated by registry operators (e.g., VeriSign for .com)

Authoritative Name Servers
├─ Hold actual DNS records for a specific domain
├─ Final authoritative answer for queries
├─ Managed by domain owner or their DNS provider
└─ Example: ns1.example.com, ns2.example.com

The Specialist Agent Analogy:

Name servers act like specialized agents with access to the authoritative source:

  • Each agent only knows their specific territory (zone)

  • Strategically deployed worldwide for accessibility

  • Provide definitive answers — no guessing


How a DNS Query Works: Step by Step

Let's trace what happens when you visit www.netflix.com for the first time.

DNS Resolution Flow
────────────────────────────────────────────────────────────

Step 1: Your Browser Checks Local Cache
┌─────────┐
│ Browser │──→ "Do I have netflix.com cached?" → NO
└─────────┘

Step 2: OS Checks Its Cache + /etc/hosts
┌──────────┐
│ Your OS  │──→ Check cache + hosts file → NO
└──────────┘

Step 3: Query Goes to Recursive Resolver
┌──────────┐        ┌────────────────────┐
│ Your OS  │──────→ │ Recursive Resolver │
└──────────┘        │ (e.g., 1.1.1.1)   │
                    └────────────────────┘
                    "Do I have netflix.com cached?" → NO

Step 4: Resolver Queries Root Name Server
┌────────────────────┐        ┌─────────────────┐
│ Recursive Resolver │──────→ │ Root Name Server│
└────────────────────┘        └─────────────────┘
  "Who handles .com?"
                              ← "Ask the .com TLD servers"
                                 (returns TLD server IPs)

Step 5: Resolver Queries TLD Name Server
┌────────────────────┐        ┌──────────────────────┐
│ Recursive Resolver │──────→ │ .com TLD Name Server │
└────────────────────┘        └──────────────────────┘
  "Who handles netflix.com?"
                              ← "Ask ns1.p13.dynect.net"
                                 (returns authoritative NS)

Step 6: Resolver Queries Authoritative Name Server
┌────────────────────┐        ┌────────────────────────────┐
│ Recursive Resolver │──────→ │ Authoritative Name Server  │
└────────────────────┘        │ (ns1.p13.dynect.net)       │
  "What is netflix.com's IP?" └────────────────────────────┘
                              ← "192.0.2.1" (actual IP)

Step 7: Answer Returned and Cached
┌────────────────────┐        ┌──────────┐
│ Recursive Resolver │──────→ │ Browser  │
│ (caches the answer)│        │ (caches) │
└────────────────────┘        └──────────┘

Step 8: Browser Connects to Netflix's Server
Browser → 192.0.2.1 → Netflix page loads ✅

Total time for this process: typically 20–120 milliseconds


Reliability: Fault Tolerance in DNS

Redundancy at Every Layer

Redundancy Architecture
────────────────────────────────────────────────────────
Root Name Servers:
├─ 13 root server identities (A-root through M-root)
├─ Each identity served by hundreds of physical servers
├─ Anycast routing sends queries to nearest instance
└─ No single point of failure at the root level

TLD Name Servers:
├─ Multiple servers per TLD
├─ .com has 13 TLD name servers globally (a.gtld-servers.net to m.gtld-servers.net)
└─ Geographically distributed across continents

Authoritative Name Servers:
├─ Domains typically configure minimum 2 name servers
├─ Best practice: 4+ servers across different providers
└─ Example: ns1.example.com + ns2.example.com

Recursive Resolvers:
├─ ISPs run multiple resolvers per region
├─ Public resolvers (1.1.1.1, 8.8.8.8) have global PoPs
└─ If one fails, queries automatically route to another

What Happens When a Server Fails?

Failure Scenario Example
────────────────────────────────────────
ns1.netflix.com goes offline
           │
           ↓
Resolver retries → ns2.netflix.com (still online)
           │
           ↓
Query succeeds ✅ — User notices nothing

This seamless failover is what makes DNS fault tolerant and highly available.


Distributed System Principles in DNS

DNS exemplifies several core principles of distributed system design:

Principle How DNS Implements It
Decentralization No single server holds all data; hierarchical delegation
Redundancy Multiple servers at every layer (root, TLD, authoritative)
Caching TTL-based caching at browser, OS, and resolver levels
Partition Tolerance Loss of one zone doesn't affect others
Geographic Distribution Servers on every continent, Anycast routing
Eventual Consistency TTL propagation ensures changes spread globally over time
Delegation Authority passed down the tree; each level manages its own zone