SystemExpertsSystemExperts
Pricing

System Design Fundamentals

11 items

Scalability Fundamentals

25mbeginner

Latency, Throughput & Performance

30mbeginner

Back-of-Envelope Calculations

25mbeginner

Availability & Reliability Fundamentals

35mintermediate

CAP Theorem & Consistency Models

40mintermediate

Load Balancing Deep Dive

35mintermediate

Asynchronous Processing & Message Queues

30mintermediate

Networking & Protocols

30mintermediate

Caching Strategies

35mintermediate

System Design Fundamentals

20mintermediate

Database Fundamentals

40madvanced
Fundamentalsnetworkingtcpudphttprestgrpcwebsocketdnsfundamentalssystem-designintermediate

Networking & Protocols

TCP vs UDP, HTTP versions, REST vs RPC - communication fundamentals

Foundation knowledge|30 min read

Summary

Understanding networking protocols is essential for system design. TCP provides reliable, ordered delivery at the cost of latency (connection setup, acknowledgments). UDP is faster but unreliable, suitable for real-time applications where stale data is useless. HTTP has evolved from HTTP/1.1 (one request per connection) to HTTP/2 (multiplexed streams) to HTTP/3 (QUIC, UDP-based). For APIs, REST is the default for CRUD operations, while gRPC excels for internal service communication with strong typing and streaming support.

Key Takeaways

TCP is Reliable but Adds Latency

TCP's three-way handshake adds one round trip before any data transfers. With TLS, add another 1-2 round trips. For short-lived connections, this overhead dominates. Solution: connection reuse, HTTP/2 multiplexing, or HTTP/3 (QUIC).

UDP Sacrifices Reliability for Speed

UDP sends packets without acknowledgment or ordering. Packets can be lost, duplicated, or arrive out of order. But for real-time applications (video, gaming, DNS), the speed advantage outweighs reliability—old data is useless anyway.

HTTP/2 Multiplexing Solves Head-of-Line Blocking

HTTP/1.1 sends one request per connection, queuing others. HTTP/2 multiplexes many requests over one connection. But TCP's ordering requirement means a single lost packet blocks all streams. HTTP/3 (QUIC) solves this at the transport layer.

TCP (Transmission Control Protocol): - Connection-oriented (handshake required) - Reliable delivery (acknowledgments, retries) - Ordered packets (sequence numbers) - Flow control (congestion handling)

UDP (User Datagram Protocol): - Connectionless (no handshake) - Unreliable (no acknowledgments) - Unordered (packets may arrive in any order) - No flow control (fast but can overwhelm)

TCP Three-Way Handshake

When to use each:

| Use Case | Protocol | Why | |----------|----------|-----| | Web/API | TCP | Reliability required | | Database | TCP | Data integrity critical | | Video streaming | UDP | Stale frames useless | | Online gaming | UDP | Low latency critical | | DNS queries | UDP | Small, fast queries | | VoIP | UDP | Real-time audio | | File transfer | TCP | Must be complete |

Summary

Understanding networking protocols is essential for system design. TCP provides reliable, ordered delivery at the cost of latency (connection setup, acknowledgments). UDP is faster but unreliable, suitable for real-time applications where stale data is useless. HTTP has evolved from HTTP/1.1 (one request per connection) to HTTP/2 (multiplexed streams) to HTTP/3 (QUIC, UDP-based). For APIs, REST is the default for CRUD operations, while gRPC excels for internal service communication with strong typing and streaming support.

Key Takeaways

TCP is Reliable but Adds Latency

TCP's three-way handshake adds one round trip before any data transfers. With TLS, add another 1-2 round trips. For short-lived connections, this overhead dominates. Solution: connection reuse, HTTP/2 multiplexing, or HTTP/3 (QUIC).

UDP Sacrifices Reliability for Speed

UDP sends packets without acknowledgment or ordering. Packets can be lost, duplicated, or arrive out of order. But for real-time applications (video, gaming, DNS), the speed advantage outweighs reliability—old data is useless anyway.

HTTP/2 Multiplexing Solves Head-of-Line Blocking

HTTP/1.1 sends one request per connection, queuing others. HTTP/2 multiplexes many requests over one connection. But TCP's ordering requirement means a single lost packet blocks all streams. HTTP/3 (QUIC) solves this at the transport layer.

REST is for Resources, RPC is for Actions

REST models operations as CRUD on resources (GET /users/123). RPC models operations as function calls (getUser(123)). REST is better for public APIs with caching; RPC is better for internal services with complex operations.

WebSockets Enable Server Push

HTTP is request-response: client initiates, server responds. WebSockets establish a persistent bidirectional channel. Use for real-time features: chat, notifications, live updates, collaborative editing.

DNS is the Internet's Phone Book

DNS translates domain names to IP addresses. DNS latency affects every first request to a domain. Use DNS caching, keep TTLs reasonable, and consider DNS for load balancing and failover (GeoDNS).

Deep Dive

TCP (Transmission Control Protocol): - Connection-oriented (handshake required) - Reliable delivery (acknowledgments, retries) - Ordered packets (sequence numbers) - Flow control (congestion handling)

UDP (User Datagram Protocol): - Connectionless (no handshake) - Unreliable (no acknowledgments) - Unordered (packets may arrive in any order) - No flow control (fast but can overwhelm)

TCP Three-Way Handshake

When to use each:

| Use Case | Protocol | Why | |----------|----------|-----| | Web/API | TCP | Reliability required | | Database | TCP | Data integrity critical | | Video streaming | UDP | Stale frames useless | | Online gaming | UDP | Low latency critical | | DNS queries | UDP | Small, fast queries | | VoIP | UDP | Real-time audio | | File transfer | TCP | Must be complete |

Trade-offs

AspectAdvantageDisadvantage
TCP vs UDPTCP: Reliable, ordered delivery; UDP: Low latency, no connection overheadTCP: Handshake latency, head-of-line blocking; UDP: No reliability, must handle packet loss
REST vs gRPCREST: Browser-native, cacheable, easy debugging; gRPC: Strong typing, streaming, high performanceREST: No streaming, text overhead; gRPC: No browser support, harder to debug
WebSocket vs PollingWebSocket: Real-time, efficient, bidirectional; Polling: Simple, stateless, works everywhereWebSocket: Stateful connections, scaling complexity; Polling: Latency, wasted requests

Premium Content

Sign in to access this content or upgrade for full access.