SYSTEM DESIGN SKETCHBOOK / VISUAL GUIDE RECAP
Follow a web request
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.
Redraw from memory (fold the page so the figure is hidden)
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 afterwards: 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: Design a weather app (No. 36 in the question bank)