map / networking / latency-budgets
Networking · principle 6 of 6
Latency budgets: what happens when you curl a URL
Light in fiber travels roughly 200 km per millisecond, so distance sets a floor on every round trip that no code can beat.
01 · Why it’s true
Signals in optical fiber travel at roughly two-thirds the speed of light in a vacuum — about 200 km per millisecond. A round trip covers the distance twice, so every 1,000 km between client and server adds at least about 10 ms of round-trip time, before any processing.
A brand-new HTTPS request needs several round trips before useful data flows: DNS (unless cached), the TCP handshake, the TLS handshake, and then the request itself. So latency is roughly the number of round trips times the round-trip time, plus server time. Removing round trips or moving closer to users usually beats optimizing code.
02 · Picture it
03 · In the interview
- “What happens when you type a URL and press Enter?” — answered as a sequence of round trips.
- Explaining why a CDN or edge proxy helps users who are far away.
- Splitting a latency target into a budget per hop in the request path.
04 · Practice question
“Our API takes 30 ms server-side, but users on another continent wait about a second for their first request. Explain.”
A strong answer covers
- Count round trips for a cold request: DNS, TCP handshake, TLS handshake, the request — plus a few more for a large response while TCP’s window grows.
- Multiply by the round-trip time for that distance; a handful of intercontinental round trips adds up to most of a second.
- Fixes: reuse connections, use TLS 1.3 and session resumption, shrink responses, and terminate connections at an edge close to users.
- Confirm with client-side timing (
curl -wbreaks out DNS, connect, TLS, and first byte).
Want to play with it? Open the interactive deep dive →