Home/Labs/Request Latency Budget
All 280 Labs
INTERACTIVE LAB⏳

Request/Response Lifecycle Lab (Interactive)

Toggle DNS, TLS, keep-alive, edge SSL, Redis, and gzip to build a per-hop latency budget. Walk a request from browser through DNS, TCP/TLS, CDN, load balancer, app server, and database, computing real millisecond totals.

Request Lifecycle Latency Budget

Browser → DNS → TCP/TLS → Edge → LB → App → Cache/DB → Render: toggle each optimization and watch the total.

Cold first request215.0 ms
warm repeat visit: 60.0 ms
DNS (cold)75.0 ms

Full recursive resolution Root → TLD → Authoritative adds ~75 ms.

TCP handshake40.0 ms

SYN → SYN-ACK → ACK costs 1 RTT (40 ms). Keep-alive amortizes it to 0.

TLS 1.3 handshake40.0 ms

TLS 1.3 folds the key share into ClientHello: 1 RTT.

Edge CDN / WAF8.0 ms

TLS termination, DDoS rate-limit rules, and header inspection at the PoP.

L7 Load Balancer6.0 ms

Path routing (/api → Orders fleet) plus X-Request-ID injection.

App server18.0 ms

JWT validation + business logic. Crypto already offloaded at the edge (frees 10–30% CPU).

PostgreSQL query12.0 ms

Cache MISS: pooled connection executes an indexed read in ~12 ms.

Response (gzip)0.0 ms

50 KB JSON compresses to 8.0 KB — 0.1 ms saved on a 5 Mbps link.

Browser render16.0 ms

DOM + CSSOM → Layout → Paint within one 16 ms frame (60 FPS budget).

NetworkSecurity/EdgeComputeStorage

How It Works Under the Hood

Every web request traverses layered infrastructure, and each layer contributes milliseconds: a cold recursive DNS lookup adds 50–100ms, the TCP handshake costs 1 RTT, TLS 1.3 another, and the edge–LB–app–DB chain another 25–50ms. The big wins are reuse: keep-alive collapses handshakes to zero, a Redis HIT answers in 0.3ms instead of a 12ms SQL query, edge TLS termination frees 10–30% of app CPU, and gzip shrinks a 50KB JSON body to 8KB. Warm cached requests complete under 50ms; cold first visits exceed 300ms.

Core Architectural Principles

  • Cold request = DNS (0–100ms) + TCP 1 RTT + TLS 1–2 RTT + edge/LB forwarding + app + DB.
  • Connection pooling avoids a fresh TCP handshake to the database on every query.
  • Response-path optimization: Brotli compression, HTTP/2 multiplexing, and Cache-Control headers eliminate round trips.
Interview Round Script

Asked "what happens when you click Submit?", walk the layers in order with numbers: "DNS adds 50–100ms cold, keep-alive makes handshakes free, a cache HIT returns in under a millisecond versus 12ms for SQL." Citing connection pooling and edge TLS termination demonstrates production awareness beyond textbook hops.

Key Trade-Offs

Each protective/routing layer (CDN, WAF, LB) adds 5–20ms of cumulative latency while providing security, scalability, and observability.

Related Curriculum Chapter

Request/Response Lifecycle (Browser → Server → DB)

Read Full Chapter Blueprint

Explore More Interactive Labs

View All 280 Labs