RECAP
What to remember
- A first page load pays for DNS, connection setup, the request, server work and the response, in that order.
- Distance is paid per round trip. TCP and TLS add round trips before the first byte of the request is sent.
- A reused connection skips setup; a nearby edge shortens setup for everyone and can skip the origin for cacheable responses.
- A slow query is server time. Only an index, a cheaper query or a cache removes it.
- Write the breakdown before choosing a fix, then attach a number to each fix.
NOW CLOSE THE GUIDE AND REDRAW IT
On a blank page, redraw the path from browser to database for a first visit. Label each stage, then mark where a slow database query adds time and where a distant server adds time. Finally, add a nearby edge and cross out the costs it removes.
Check your drawing against this list afterwards, not before:
- DNS lookup through a resolver, with the authoritative server only on a cache miss.
- TCP and TLS shown as round trips to the distant server before the request.
- Server work split into app code and the database query, with the slow query marked.
- The response path back to the browser.
- A nearby edge that shortens connection setup and keeps a warm connection to the origin.
- A note on what the edge cannot fix (the uncached slow query).
APPLY IT
Sketch a weather app
GO DEEPER WITH OUR GUIDES
OFF-SITE SOURCES · NOT WRITTEN BY US
Sources and further reading
- High Performance Browser Networking
Free book that explains latency, TCP, TLS and HTTP/2 from first principles. The chapters on TCP and TLS show where each round trip comes from.
- Populating the page: how browsers work
Walks through DNS, the TCP and TLS handshakes and the first response from the browser's point of view.
- RFC 8446: TLS 1.3
The protocol spec. Section 2 gives an overview of the full handshake and why 1.3 needs one round trip before application data.
- What is a CDN?
Short vendor explainer on how edge servers shorten distance and cache responses near users.