Skip to content
Low Level Design Mastery Logo
LowLevelDesign Mastery

Networking Fundamentals

Understanding transport layer impact on application design

Understanding networking fundamentals is crucial for designing distributed systems. The transport layer protocols you choose directly impact:

  • Latency: How fast data travels
  • Throughput: How much data can be sent
  • Reliability: Whether data arrives correctly
  • Application design: How you structure your code
Diagram

TCP is connection-oriented and provides reliable, ordered delivery of data.

Characteristics:

  • Connection-oriented: Establishes connection before data transfer
  • Reliable: Guarantees delivery (acknowledgments, retransmissions)
  • Ordered: Data arrives in order
  • Flow control: Prevents sender from overwhelming receiver
  • Congestion control: Adapts to network conditions

Use Cases:

  • Web browsing (HTTP/HTTPS)
  • File transfers
  • Email (SMTP)
  • Database connections
  • Any application requiring reliable delivery

Trade-offs:

  • Higher latency (connection establishment, acknowledgments)
  • More overhead (headers, control messages)
  • Slower for small messages (connection setup cost)

UDP is connectionless and provides unreliable, unordered delivery.

Characteristics:

  • Connectionless: No connection establishment
  • Unreliable: No delivery guarantees
  • Unordered: Data may arrive out of order
  • No flow control: Can overwhelm receiver
  • No congestion control: Can congest network

Use Cases:

  • Real-time gaming
  • Video streaming
  • DNS queries
  • Voice over IP (VoIP)
  • Any application prioritizing speed over reliability

Trade-offs:

  • Lower latency (no connection setup)
  • Less overhead (smaller headers)
  • Faster for small messages
  • No delivery guarantees
Diagram

DNS translates human-readable domain names (like example.com) to IP addresses (like 192.0.2.1).

Diagram

DNS Resolution Steps:

  1. Client queries local DNS server (usually ISP or configured resolver)
  2. If not cached, local DNS queries root DNS server
  3. Root server refers to TLD server (.com, .org, etc.)
  4. TLD server refers to authoritative DNS server
  5. Authoritative server returns IP address
  6. Response cached at multiple levels

Performance Impact:

  • First lookup: 20-120ms (multiple round trips)
  • Cached lookup: less than 1ms (from cache)
  • DNS failures: Complete service outage (can’t resolve domain names)

Best Practices:

  • Cache DNS responses (TTL-based)
  • Use multiple DNS servers for redundancy
  • Monitor DNS resolution time
  • Consider DNS prefetching for web applications

HTTP/2 is a binary protocol that improves upon HTTP/1.1 with multiplexing, header compression, and server push.

Multiplexing:

  • Multiple requests over single TCP connection
  • Eliminates head-of-line blocking
  • Better connection utilization

Header Compression:

  • HPACK compression reduces header size
  • Especially beneficial for small requests with large headers

Server Push:

  • Server can push resources before client requests them
  • Reduces round trips

Binary Protocol:

  • More efficient than text-based HTTP/1.1
  • Easier to parse
Diagram

Impact on Application Design:

  • Connection pooling less critical (single connection handles multiple requests)
  • Reduced latency for multiple requests
  • Better for applications making many small requests

QUIC (Quick UDP Internet Connections) is a UDP-based transport protocol developed by Google. It provides TCP-like reliability with lower latency.

Built-in Encryption:

  • TLS 1.3 encryption built into protocol
  • Reduces connection establishment overhead

Connection Migration:

  • Connection survives IP address changes
  • Better for mobile devices switching networks

Multiplexing:

  • Multiple streams over single connection
  • Eliminates head-of-line blocking

Faster Connection Establishment:

  • 0-RTT for repeat connections
  • 1-RTT for new connections (vs 3-RTT for TCP+TLS)
Diagram

Use Cases:

  • HTTP/3 (replaces TCP+TLS for HTTP)
  • Mobile applications (handles network changes)
  • High-latency networks (faster connection establishment)
  • Applications requiring low latency

Problem: Creating new TCP connections is expensive (3-way handshake).

Solution: Reuse connections via connection pooling.

For high-throughput applications, use async I/O to handle many connections efficiently.

Benefits:

  • Handle thousands of connections with few threads
  • Better resource utilization
  • Lower latency (no blocking on I/O)

Use Cases:

  • High-concurrency servers
  • Real-time applications
  • Microservices with many connections

Choose TCP when:

  • Reliability is critical (database, file transfer)
  • Order matters (streaming, transactions)
  • Flow control needed (large transfers)

Choose UDP when:

  • Speed/latency is critical (gaming, VoIP)
  • Small messages (DNS queries)
  • Can tolerate packet loss (real-time streaming)
  • Need multicast (broadcasting)

Choose HTTP/2 when:

  • Making many requests to same server
  • Want to reduce latency
  • Need header compression benefits

Choose QUIC/HTTP/3 when:

  • Mobile applications (network switching)
  • High latency networks
  • Want fastest connection establishment
  • Need connection migration

TCP vs UDP

TCP provides reliability and ordering at cost of latency. UDP provides speed at cost of reliability. Choose based on requirements.

DNS Impact

DNS resolution adds latency (20-120ms first lookup). Cache DNS responses. DNS failures cause complete outages.

HTTP/2 Benefits

Multiplexing, header compression, server push reduce latency. Single connection handles multiple requests efficiently.

QUIC Advantages

Faster connection establishment, built-in encryption, connection migration. Better for mobile and high-latency networks.