Back to the guide

SYSTEM DESIGN SKETCHBOOK / VISUAL GUIDE RECAP

Follow a web request

Foundations & estimation · free to copy and share

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.
shop.example?SQL queryshort hopwarm connectionBrowserMumbaiDNS resolvercaches answersAuthoritativeDNSNearby edgealso MumbaiApp serverVirginiaDatabaseindexed, ~15 ms
A browser looks up a name through a DNS resolver, opens a connection to a distant app server that queries a database, and later goes through a nearby edge that keeps a warm connection to the server.

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)