Type a URL, hit enter. In about 200 milliseconds, your laptop finds an unrelated machine somewhere in the world, agrees on a shared encryption key with it, asks it a question, and renders the answer. Almost every layer of that trip is a place your app can break.
← Back to APIs & Networkingexample.com → 93.184.216.34. Your OS asks a resolver, which asks the root, the TLD, then the authoritative server. Cached aggressively.GET /path HTTP/1.1 + headers + body.| Layer | What It Does | You'll See |
|---|---|---|
| Application | What humans care about | HTTP, gRPC, WebSocket, DNS, SMTP, SSH |
| Transport | Reliable (or fast) delivery between programs | TCP, UDP, QUIC |
| Network | Routing packets between machines, anywhere | IP (v4/v6), ICMP |
| Link | Moving frames over a single hop of cable/wifi | Ethernet, Wi-Fi, MAC addresses |
| Physical | Electrons, light, radio | Cables, fibre, antennas |
Most of your career will live in the top two layers. When something feels broken below them — packet loss, MTU issues, asymmetric routing — that's when you call the network team.
Hierarchical, cached, and slower than you think on a cold lookup. Records you'll touch: A (IPv4), AAAA (IPv6), CNAME (alias), MX (mail), TXT (verification, SPF/DKIM), NS (delegation).
The TTL is a contract. Set it short before a migration, long for stability. "DNS hasn't propagated yet" almost always means a cache somewhere is honoring an old TTL.
TCP guarantees ordered, reliable bytes. Costs: handshake, retransmits, head-of-line blocking. The web rides on this.
UDP is fire-and-forget. No handshake, no retransmit. Used for DNS, video, games, VoIP — anywhere "stale" beats "late."
QUIC is UDP with the good parts of TCP rebuilt in user space — faster handshake, no head-of-line blocking, connection migration across networks. It's the foundation of HTTP/3.
TLS does two jobs: encrypt the channel and authenticate the server (and optionally the client) via certificates signed by a CA. Your browser ships with a list of trusted CAs; the server presents a chain that ends at one.
Things to know: certs expire (set up auto-renewal — Let's Encrypt + cert-manager); SNI lets one IP host many domains; mTLS adds client certs for service-to-service trust; HSTS tells browsers to refuse HTTP for your domain forever.
IP identifies a machine; port identifies a program on it (80 = HTTP, 443 = HTTPS, 22 = SSH, 5432 = Postgres). IPv4 ran out of addresses years ago — IPv6 has 2¹²⁸ of them. NAT lets a whole home network share one public IPv4 by rewriting source addresses.
By default a page on a.com cannot read responses from b.com. The server at b.com opts in by sending Access-Control-Allow-Origin. For non-trivial requests the browser first sends an OPTIONS preflight asking permission.
CORS is enforced by the browser, not the server. curl ignores it entirely — that's why the same call works in your terminal and fails in your app.
A load balancer spreads traffic across many backend servers. L4 (TCP) ones route on IP/port; L7 (HTTP) ones route on path, header, cookie. Algorithms: round-robin, least-connections, IP hash for sticky sessions.
A reverse proxy (nginx, HAProxy, Envoy, Cloudflare, AWS ALB) sits in front of your app and does TLS termination, caching, rate-limiting, header rewrites, and load balancing. Almost every production app has one.
Cloudflare, Fastly, CloudFront, Akamai. Hundreds of edge locations cache static assets and increasingly run code. Cache-Control headers tell the CDN how long to hold a response; cache keys decide what counts as "the same" request. Get the keys wrong and one user's data leaks to another.
A cookie is just a header the browser echoes back. Flags that matter: Secure (HTTPS only), HttpOnly (no JS access), SameSite=Lax/Strict/None (cross-site behavior). Modern browsers default to Lax, which kills most CSRF — but you still need to think about it.
| Tool | What It's For |
|---|---|
dig / nslookup | Inspect DNS records and resolver chain. |
curl -v | See the full request, response headers, and status. |
ping / traceroute | Reachability and the path packets take. |
openssl s_client | Inspect a TLS handshake and certificate chain. |
tcpdump / Wireshark | Packet capture for the hard cases. |
| Browser DevTools → Network | Waterfall, timing, headers, response. The first place to look on the client side. |