Skip to main content
networking

HTTP request lifecycle — animated end-to-end

14 min read
Fully authored

A checkout API request from browser click to backend response — DNS, TCP, TLS, LB routing, backend. HTTP vs HTTPS side-by-side.

Alice clicks "Place Order" on a merchant site. In less than a second, her browser talks to seven different systems across three continents. She types nothing, sees no errors, and doesn't know that DNS was resolved, TCP was handshaken, TLS was negotiated, a CDN was hit and missed, a load balancer picked one of three application servers, an auth token was verified, a Redis rate limit was checked, and a Postgres row was updated — all before the "Success" toast rendered.

Understanding this lifecycle in detail is what separates "I can write a web app" from "I can debug why my web app is slow." Every one of those seven steps is a place where latency accumulates, where authentication decisions happen, where errors originate, and where caching can save the day. The interview version of this question — "walk me through what happens when you type a URL and press Enter" — is deliberately open-ended because a Staff-level candidate can keep unpacking it for 45 minutes.

We'll trace a concrete scenario: Alice's browser calls POST https://checkout.acme.com/api/v1/orders. Behind that URL sits a real production stack — Cloudflare CDN, AWS ALB, three EC2 pods with private IPs, Redis for rate limiting, and Postgres for orders. We'll follow every packet, every header, every round trip. And then we'll toggle to see what changes if the same request went over plaintext HTTP instead of HTTPS.

Prerequisites & cross-references

  • DNS + TLS + HTTP/HTTPS concepts — this deep-dive integrates all of them. Read them individually first if you need refreshers.
  • L4 vs L7 Load Balancer the deep-dive explains why our path lands at ALB (L7) not NLB (L4).
  • Idempotency — the checkout POST includes an Idempotency-Key header for retry safety. See the deep-dive.

The concrete scenario

Alice's checkout: POST https://checkout.acme.com/api/v1/orders
  Alice (Bangalore)
   ↓  (residential DSL, 40ms to nearest CDN PoP)
  Cloudflare edge (Mumbai PoP)
   ↓  (backhaul 200ms to US-East)
  AWS ALB (us-east-1a)   ← L7 · terminates TLS · WAF · path routing
   ↓  (private VPC, 1ms)
  Backend pool:
    checkout-svc-pod-0   10.0.1.15  (us-east-1a)
    checkout-svc-pod-1   10.0.2.22  (us-east-1b)
    checkout-svc-pod-2   10.0.3.31  (us-east-1c)
   ↓  (auth check + rate limit)
  Redis cluster (session + rate limit)  10.0.4.10
   ↓  (business logic + write)
  Postgres primary (Multi-AZ)  10.0.5.10
   ↓  (2ms + fsync)
  ~ response bubbles back the same path ~

Step-by-step walkthrough

Click any step to zoom in. The timing shows what Alice's browser sees on a good network (median residential DSL from Bangalore to a US-East region). The right column shows what actually happens under the hood.

Step 1
0 ms

URL parse + HSTS check

Browser parses https://checkout.acme.com/api/v1/orders. Local HSTS list (preloaded + previously observed) says 'this host requires HTTPS'. If the URL had been http://, the browser would refuse or upgrade internally.

What's on the wire: Nothing on wire yet. Cached HSTS check is memory-only.

Same request, plaintext HTTP — what changes?

Suppose the merchant hadn't configured HTTPS. Or the DNS pointed at port 80 without redirecting. What does the same checkout call look like?

Plaintext HTTP (port 80)
  • No TLS handshake. Saves 1 RTT of setup latency.
  • Every byte visible on wire. Authorization headers, cookies, request bodies, response bodies all plaintext.
  • Attacker on Wi-Fi sees everything. Coffee shop, hotel Wi-Fi, ISP-level surveillance.
  • Redirect to HTTPS if HSTS. Modern browsers upgrade automatically for known hosts.
  • "Not Secure" warning. Chrome, Firefox, Safari all display red warning icons for plaintext HTTP.
  • No HTTP/2 or HTTP/3. Both browsers and servers require TLS for HTTP/2. HTTP/3 (QUIC) requires TLS 1.3.
HTTPS (port 443)
  • TLS 1.3 handshake adds 1 RTT. Or 0 RTT with session resumption.
  • All traffic encrypted end-to-end (between TLS endpoints). Attacker sees only ciphertext + SNI + connection metadata.
  • Server authenticated via certificate. Alice's browser knows she's talking to the real acme.com, not an impersonator.
  • HTTP/2 multiplexing + HTTP/3 QUIC. Modern performance features only available over TLS.
  • HSTS enforced. Once seen, browser refuses to downgrade to HTTP even if user types http://.
  • ~5-10 ms extra overhead per request. For certificate parsing + AES-GCM decryption. Negligible on modern hardware.

The killer insight: every header, body, and response is visible on the wire when using HTTP. Any router, any Wi-Fi node, any coffee-shop attacker with tcpdump sees Alice's Authorization: Bearer eyJ... token. Modern browsers refuse to send credentials over plaintext HTTP by default; if you type http://checkout.acme.com into Chrome, it redirects to HTTPS via HSTS preload before even resolving DNS. This is why HTTP-only public sites are near-extinct in 2025.

Where latency accumulates

PhaseCold (first visit)Warm (returning)Optimization lever
DNS20–100 ms0 ms (cached)DNS prefetch hint · long TTL · DoH
TCP handshake40 ms (1 RTT)0 ms (keep-alive)HTTP/2 keep-alive · HTTP/3 QUIC (no TCP handshake)
TLS handshake40 ms (1 RTT, TLS 1.3)0 ms (0-RTT resume)TLS 1.3 · session resumption · 0-RTT
CDN edge processing5–20 ms5–20 msMove logic to edge (Cloudflare Workers)
CDN → origin backhaul100–300 ms (WAN)100–300 msOrigin shield · edge cache HIT · closer origin
ALB routing1–5 ms1–5 msL4 NLB is faster; L7 ALB is smarter
Backend + DB10–50 ms10–50 msRedis cache · async DB writes · connection pooling
Total end-to-end~215–515 ms~115–375 msEvery optimization compounds

Common optimizations, in order of impact

  1. Cache the DNS lookup. Browser DNS cache saves 20-100ms per request after the first. Set your ttl on the DNS record deliberately — too short means clients rebeat your nameservers; too long means IP changes take hours to propagate.
  2. Keep TCP connections alive. HTTP/1.1 keep-alive reuses the same TCP + TLS pipeline for multiple requests. HTTP/2 goes further with multiplexing. HTTP/3 uses QUIC over UDP to skip TCP handshake entirely after the first request.
  3. TLS 1.3 with 0-RTT resumption. First connection is 1 RTT (down from TLS 1.2's 2 RTT). Resumed connections are 0 RTT — the client can send encrypted data in the very first packet.
  4. CDN edge caching for static assets. HTML + JS + CSS + images cached at 300+ Cloudflare PoPs means Alice's browser fetches them 10-100ms away instead of crossing continents. Origin sees only cache misses.
  5. Move rate limit checks to the edge. If your rate limit is per-API-key, run the check in a Cloudflare Worker before ever hitting your origin. Saves the entire backend round-trip for rejected requests.
  6. Prefetch DNS + preconnect TLS. Browsers support <link rel="dns-prefetch"> and <link rel="preconnect"> hints. Use them for third-party origins your page will hit.

Real-world request tracing

Google

QUIC + HTTP/3 gives them ~20% latency reduction

Google Search, YouTube, and Chrome all default to HTTP/3 (QUIC over UDP). Combined with 0-RTT TLS 1.3, a returning user's first request is faster than DNS resolution of any competing site.

Cloudflare

99% of TLS handshakes are resumed

Because Cloudflare terminates TLS at 300+ PoPs and broadcasts session tickets across them, most repeat visitors hit 0-RTT resumption. Their published stat: 99% TLS resumption rate globally.

Netflix

Open Connect appliances remove the WAN entirely

Netflix ships physical CDN boxes to major ISPs. Alice's video request never leaves her ISP's network — no WAN latency, no CDN edge lookup, direct fetch. Cuts time-to-first-byte to milliseconds.

Stripe

Every checkout POST has an Idempotency-Key

Their client library auto-generates a UUID. Server dedupe via Redis with 24-hour TTL. Retry-safe from day one. Documented at stripe.com/docs/api/idempotent_requests.

Interview answer template

Q: Walk me through what happens when I click "Place Order" on this page.

A (structure your answer in these 7 phases, go deep on 1-2 they push on):

  1. URL parsing + HSTS check — browser checks local HSTS list, upgrades to HTTPS.
  2. DNS resolution — browser cache → OS cache → resolver → root → TLD → authoritative NS. Returns CDN IP.
  3. TCP handshake — SYN, SYN-ACK, ACK to the CDN IP on port 443.
  4. TLS handshake — ClientHello with SNI, ServerHello, cert chain, key exchange, Finished. Then application data.
  5. HTTP request through CDN — cache lookup; HIT returns from edge, MISS forwards to origin.
  6. Load balancer routing — ALB inspects path, picks target group + backend pod based on round-robin or least-conn.
  7. Backend processing — auth check, rate limit (Redis), business logic, DB write, response construction. Response bubbles back up.

Follow-up probes to be ready for:

  • "What's in the TLS ClientHello?" → cipher suites, SNI, ALPN (HTTP/2 negotiation), key share for 0-RTT.
  • "How does the CDN know when to invalidate a cached response?" → Cache-Control headers, purge API, surrogate keys, tag-based invalidation.
  • "What happens on retry?" → Idempotency-Key, 409 Conflict on concurrent retry, exponential backoff.
  • "How would you cut this end-to-end from 300ms to 50ms?" → CDN caching, TLS 1.3 0-RTT, HTTP/3, connection pooling, edge rate limits, prefetch/preconnect hints.

Key takeaways

  1. An HTTPS request talks to at least 7 systems between the browser and the database — every one adds latency and can fail.
  2. DNS + TCP + TLS handshake dominate cold-start latency. Optimizations focus on skipping repeated handshakes (keep-alive, HTTP/2, 0-RTT TLS 1.3, HTTP/3).
  3. Plaintext HTTP means everything is visible on the wire. HSTS preload + browser policy make HTTP-only public sites near-extinct in 2025.
  4. CDNs eliminate WAN latency for cacheable content. Netflix Open Connect and Cloudflare edge caches remove the round trip to origin for repeat requests.
  5. Layered defense at every stage — HSTS at browser, TLS between edges, WAF at CDN, LB routing at ALB, rate limits at Redis, auth at backend. Attacker must break all of them.

Practice what you just read

Every foundation concept has a companion quiz to close the loop.