Hussein's channel is the gold standard for networking depth. Watch these two videos for visual walkthroughs.
Every web request starts with networking. Before a single line of your application code runs, DNS resolves the domain, TCP establishes a connection, TLS negotiates encryption, and HTTP/2 multiplexes streams. Understanding this chain helps you identify where latency hides.
DNS translates a human-readable domain (api.twitter.com) into an IP address (104.244.42.1). It's the phone book of the internet.
TTL (Time To Live) — DNS records are cached at each step for TTL seconds. Short TTL = fast failover but more DNS traffic. Long TTL = better performance but slow propagation of changes.
GeoDNS — DNS can return different IPs based on the requester's location, routing US users to US servers and Asian users to Asian servers.
Three-way handshake: SYN → SYN-ACK → ACK
Guarantees delivery and ordering
Retransmits lost packets
Use: HTTP, databases, email, file transfer
Cost: ~1 RTT overhead to establish
No handshake — fire and forget
No delivery guarantee, no ordering
No retransmission
Use: DNS, video streaming, gaming, VoIP
Cost: lowest possible overhead
Use TCP when data loss is unacceptable (payments, messages, file uploads). Use UDP when speed matters more than completeness (live video, DNS lookups, real-time gaming).
HTTP/1.1 opens a new TCP connection per request (or reuses one serially — one request at a time). Head-of-line blocking is a major problem: if one request is slow, everything behind it waits.
HTTP/2 multiplexes multiple requests over a single TCP connection. No head-of-line blocking. Also compresses headers. Standard for modern web.
WebSockets — upgrade an HTTP/1.1 connection to a persistent, bidirectional channel. Used for chat, real-time notifications, collaborative editing. See Lesson 23.
Client → [Forward Proxy] → Internet
Client sends requests through the proxy.
The server sees the proxy's IP, not the client.
Use cases:
- Corporate network filtering
- VPNs and anonymization
- Caching outbound requests
Internet → [Reverse Proxy] → Backend Servers
Client sends to proxy, proxy routes to backend.
Client sees only the proxy's IP.
Use cases:
- Load balancing
- SSL termination
- Caching responses
- DDoS protection (WAF)
- NGINX, CloudFront, API Gateway
In interviews, "proxy" usually means reverse proxy. Load balancers, CDNs, and API gateways are all forms of reverse proxies.
| Operation | Latency | Implication |
|---|---|---|
| RAM read | ~100 ns | In-memory cache is nearly instant |
| SSD read | ~16 μs | Fast but 160× slower than RAM |
| Datacenter round trip | ~500 μs | OK for most service calls |
| Cross-continent RTT | ~150 ms | Do NOT do this in a hot path |