Chapter 5: DNS, IP, TCP/UDP — The Network Foundation

DNS: The Internet's Phone Book

User types: www.example.com │ ▼ Browser cache → OS cache → Router cache → ISP DNS │ (miss at all levels) ▼ Root DNS (.com) → TLD DNS (example.com) → Authoritative DNS │ ▼ Returns: 93.184.216.34 (IP address) │ ▼ Browser connects to 93.184.216.34:443

DNS in System Design

TCP vs UDP

AspectTCPUDP
ConnectionConnection-oriented (3-way handshake)Connectionless
ReliabilityGuaranteed delivery, orderingBest-effort, may lose packets
OverheadHigher (headers, ACKs, retransmits)Lower (minimal headers)
Use casesHTTP, gRPC, database connectionsDNS, video streaming, gaming, VoIP

TCP Connection Lifecycle

// 3-way handshake (connection setup): ~1 RTT
Client → SYN → Server
Client ← SYN+ACK ← Server
Client → ACK → Server
// Now connected. Add TLS handshake: +1-2 RTT
// Total setup: 2-3 RTT before first byte of data
// At 40ms RTT (US coast-to-coast): 80-120ms just to connect!
// → This is why connection reuse (keep-alive, HTTP/2) matters

Key Networking Concepts for System Design

💡 Latency Dominates

For most web services, latency (not bandwidth) is the bottleneck. A 1KB response over a 1Gbps link takes 0.008ms to transmit but 40ms for the round trip. Reducing round trips (caching, CDN, connection reuse) matters more than increasing bandwidth.

Key Takeaways