System Design · 01. Foundations · 8 min · Beginner

How a Request Travels

Follow one page load from the address bar to the screen.

In short

One page load used four round trips (DNS, TCP, TLS, HTTP) and took 300 ms in our setup. The network took 73% of that.

The path is always the same: name to address, connect, secure, request, work, response, draw. Later lessons shorten it: caches skip work, CDNs shorten distance, and load balancers spread the server's job.

Key ideas

  • A round trip is one message out and one answer back. Most of the delay in a page load is waiting for round trips, not computing. (step 1)
  • Inside the data centre the database is a short hop away, often well under 1 ms, so the query time dominates there, not the network. (step 5)
  • To speed up a request, first remove round trips: cache DNS, reuse connections, serve from a server near the user. (step 8)

Good to know

  • DNS answers carry a TTL (time to live), often minutes to hours, so most lookups never leave your device. (step 2)

Watch out

  • Nothing useful has been sent yet, and 120 ms are gone. Reusing an open connection (keep-alive) avoids paying this again. (step 3)
  • Around 100 ms feels instant, and 300 ms is noticeable. Every extra file the page needs adds more waiting. (step 7)
DNS resolverBrowserWeb serverDatabase

Key numbers

Total time
300 ms
Round trips
4

Terms

DNS lookup
Asking a resolver which IP address belongs to a name such as shop.example.
IP address
The number that identifies a machine on the network, like 203.0.113.7.
Round trip
One message out and the answer back; its time is the round-trip time (RTT).
TCP handshake
A three-message exchange that opens a reliable connection before data is sent.
TLS
The encryption layer behind https; TLS 1.3 sets it up in one round trip.
HTTP request
A message such as GET /cart that asks a server for a resource.
HTTP status code
A number in the response that tells the result, such as 200 OK or 404 Not Found.
Keep-alive connection
Reusing an open connection for later requests so the handshakes are paid only once.
Rendering
The browser turning HTML, styles and scripts into pixels on the screen.