CAPSTONE: TRACE A REQUEST
From the browser to the database and back, and where each millisecond goes
RTT 40 ms, nothing reused: DNS from the resolver 50 ms, TCP 40 ms, TLS 1.3 45 ms, the request 40 ms, LB 1 ms, app 20 ms, new DB connection 15 ms, query 4 ms. Which single change saves the most on the second request?
A request is a chain of hops, and each hop has a price. DNS costs nothing from the browser cache, about 10 ms from a warm resolver, and much more when the resolver has to ask the authoritative server. A new connection costs a TCP round trip and a TLS round trip before the request leaves. Then the request round trip, the load balancer, the app, and the database. A new DB connection adds its own handshake and authentication.
Latency work is mostly about not paying setup twice: cache the name, keep the connection, resume TLS, pool the database.
browser ── DNS? ──► resolver ──► (root, TLD) ──► authoritative
│
├── TCP SYN/SYN-ACK ─────► edge LB 1 RTT (skip if keep-alive)
├── TLS 1.3 ─────────────► edge LB 1 RTT (ticket: no cert work)
├── HTTP request ────────► edge LB ─► app 1 RTT + 1 ms
│ app ─► DB pool ─► query
◄── first byte ───────────────────────────────────────────
new connection = DNS + 2 RTT before the request even leaves Read the hop rows. NAIVE pays DNS, TCP, TLS and a DB connection on every request and lands at 215 ms each time. TUNED pays setup once, then 65 ms. With a CONNECTION RESET, the DNS cache and the TLS ticket keep the reconnect at 146 ms. Drag the RTT up to see when the first request stops fitting.
The tuned setup keeps every request under 200 ms. Inject one fault, at one point, that pushes a request over budget. Some faults look scary and cost almost nothing.
GOAL: a request goes over the 200 ms budget
Plan the hops for one request. Return a list drawn from dns-cache, dns-resolve, tcp-connect, tls-full, tls-resume, send, lb, app, db-pool, db-connect, db-query. Use every cache that is valid at req.now, and never one that is not. caches is { dns: { [host]: { expires } }, conn: { [host]: { open } }, tickets: { [host]: { expires } }, dbIdle }.
Browser DevTools and the Resource Timing API split each request into DNS, connect, TLS and TTFB. Distributed tracing (OpenTelemetry) shows the server-side hops. Typical fixes: DNS TTLs in minutes rather than 0, keep-alive and HTTP/2 or HTTP/3 connection reuse, , TLS tickets, warm DB pools, and an edge close to users.
“What happens when you type a URL and press Enter?”, then “the page is slow; where does the time go?” Walk the hops in order with rough costs in round trips. Then name the cache that removes each one and the event that invalidates it (TTL expiry, idle timeout, deploy, new network).