Networking & Protocols
Pick the right transport and wire protocol for latency, reliability, and streaming.
In plain words
Protocols are agreed rules for how computers talk. TCP makes sure every message arrives in order, UDP is faster but may drop messages, and HTTP is the language of the web on top of them.
Think of it like…
TCP is registered certified mail with receipts; UDP is throwing postcards over a fence - faster, with no guarantee they arrive in order.
Where you’ve seen it
Loading a web page uses HTTP over TCP, so nothing gets lost. A video call uses UDP, because a dropped frame is better than a frozen screen while waiting for a resend.
Words you’ll hear
- TCP
- Reliable, ordered delivery; retries anything that gets lost.
- UDP
- Fast, fire-and-forget delivery with no guarantees.
- TLS
- Encryption that turns HTTP into HTTPS.
- Latency
- How long a message takes to travel from one machine to another.
Visual diagram
Theory & deep dive
TCP vs. UDP: reliability vs. real-time speed
TCP guarantees every byte arrives in exact order. If packet #4 gets lost, TCP pauses delivering packets #5, #6, and #7 until #4 is retransmitted. That’s essential for loading a webpage, downloading a file, or running a bank transaction.
UDP sends packets without checking if every single one arrived. On a live Zoom call or online shooter game, waiting 200 ms to re-fetch a dropped frame from 0.2 seconds ago ruins the call - better to skip it and show the latest video frame now.
HTTP/1.1 → HTTP/2 → HTTP/3 (QUIC) & gRPC
HTTP/1.1 processed one request per TCP connection at a time, forcing browsers to open 6 parallel connections. HTTP/2 multiplexes dozens of parallel streams over one TCP connection with compressed headers.
HTTP/3 (over QUIC/UDP) fixes TCP’s head-of-line blocking on lossy mobile Wi-Fi/5G and reconnects seamlessly when your phone switches from Wi-Fi to cellular. Meanwhile, gRPC uses HTTP/2 + compact binary Protobuf payloads for ultra-fast service-to-service communication.
How it works, step by step
Step 1 of 41. Transport layer: TCP vs. UDP
TCP guarantees ordered, lossless delivery with congestion control (3-way handshake). UDP sends independent datagrams with zero connection state.
- TCP Handshake
- 1 RTT (+1–2 TLS)
- UDP Overhead
- 8-byte header
When to use it & trade-offs
What it is
Protocols govern how bytes move between clients and services - from TCP/UDP at L4 to HTTP/2, HTTP/3 (QUIC), gRPC, and TLS at the session/application boundary.
Why it matters: Choosing TCP vs. UDP or HTTP/1.1 vs. HTTP/2/gRPC directly shapes head-of-line blocking, mobile reconnect speed, and video/gaming jitter.
When to reach for it
- REST/JSON at the public API edge; gRPC between internal backend services
- HTTP/3 (QUIC) for mobile-heavy apps switching between Wi-Fi and cellular
- UDP/WebRTC for sub-200 ms audio/video calls where stale packets should be dropped
When to avoid or be careful
- Opening a fresh TCP + TLS connection for every internal microservice call
- Running real-time voice/video over TCP (retransmissions stall the entire stream)
Protocol Selection Matrix
Strengths: Universal tooling, human-readable JSON, native HTTP caching.
Watch out: Larger text payloads and looser schema enforcement without OpenAPI.
Strengths: Strict typed contracts, compact binary frames, streaming, deadlines.
Watch out: Requires gRPC-Web proxy for browsers; binary payloads harder to inspect casually.
Strengths: No cross-stream TCP head-of-line blocking; fast connection migration.
Watch out: Must implement reliability/congestion logic (or rely on QUIC/WebRTC).
Interview signals & numbers to know
When this topic comes up
- video call
- low latency mobile
- internal RPC
- streaming
- binary protocol
Benchmarks & rules of thumb
- TCP + TLS 1.3 handshake
- 2 RTT cold (1 RTT TFO)
- Protobuf vs JSON size
- ~3–10× smaller
- MTU typical Ethernet
- 1,500 bytes
- Voice/video target latency
- <150 ms
Common mistakes & follow-ups
Common interview mistakes
- Forgetting TCP head-of-line blocking still affects HTTP/2 when a single packet is lost
- Using REST polling for high-frequency internal streams where gRPC streaming fits naturally
- Not configuring RPC timeouts/deadlines on gRPC or HTTP clients
Likely interviewer follow-ups
- Why did HTTP/3 move from TCP to UDP (QUIC)?
- How does connection migration in QUIC help mobile users walking out of Wi-Fi range?
- When would you keep REST instead of switching everything to gRPC?
Knowledge check
Put it into practice
Design full architectures with AI feedback
Apply Networking & Protocols inside real High-Level Design prompts or review Q&A flashcards.