Skip to content
learn
  1. Learn
  2. High Level System Design
  3. Orientation

System Design HLD-00.02

What happens when you type a URL and press Enter

Follow one page load hop by hop: caches, DNS, TCP, TLS, HTTP, CDN, servers and rendering, and see where time goes and where things fail.

Beginner 15 min Last reviewed

The big idea

Typing https://shop.example.com/cart and pressing Enter feels instant, but in that half second your browser holds a dozen conversations with machines around the world. It finds out where the shop lives, opens a connection, agrees on encryption, asks for the page, and then asks again for every image, script and font the page needs.

Every one of those steps is a place where time is spent, where a cache can skip the work, and where something can fail. Almost every topic in system design, from DNS to CDNs to databases, is about making one of these hops faster, cheaper or more reliable. This lesson walks the whole path once, so later lessons have a map to hang on.

Think of sending a letter to a company you have never written to. First you look up the address, then you check the post office will deliver there, then you seal the envelope so nobody can read it, and only then does the actual question go in the post. The answer comes back the same way.

How it works

Step 1: Read the URL

The URL is an instruction in parts:

  • https is the schemeThe protocol the browser should use. https means HTTP protected by TLS encryption.: use HTTP over an encrypted connection, on port 443 by default.
  • shop.example.com is the hostnameThe human-readable name of the machine or service to contact, such as shop.example.com.: who to talk to.
  • /cart is the path: what to ask for. Anything after ? is the query string, and anything after # stays in the browser.

Step 2: Check the caches first

Before going anywhere, the browser checks whether it already has what it needs. It may have the page itself in its HTTP cacheCopies of earlier responses the browser keeps, reused while the server's caching headers say they are still fresh., and it almost certainly has recent DNS answers cached. Skipping a step entirely is the biggest speed-up there is, which is why caching appears at every layer of every system.

Step 3: Walk the whole path

Here is the full journey for a first visit, with nothing cached. Press Next to move one hop at a time; the right margin shows typical times for a user on the same continent as the server.

One page load from browser to database and back A sequence diagram with five lanes: browser, DNS resolver, CDN edge, app server, database. Messages in order: DNS question and answer, TCP handshake, TLS handshake, the GET request, the CDN forwarding to the app server, the app querying the database, the response flowing back, then asset requests and rendering. Browser DNS resolver ISP or public CDN edge nearby city App server data center Database Where is shop.example.com? 0 to 100 ms It is 203.0.113.7 TCP: SYN 1 round trip SYN-ACK TLS: hello, keys 1 round trip GET /cart Not cached: forward 5 to 50 ms auth, business logic 1 to 20 ms SELECT cart items 1 to 10 ms rows 200 OK + HTML 200 OK + HTML first byte GET css, js, images parallel render the page Figure 1. The full path of a first visit. Each arrow is a hop that adds time, can be cached, and can fail. Times are typical orders of magnitude, not exact values.
  1. Where is shop.example.com? The resolver answers from its cache or walks the DNS tree: root, then .com, then example.com's own name server.
  2. It is 203.0.113.7 The answer comes back with a time to live, so the browser and resolver can reuse it for a while.
  3. TCP: SYN The browser opens a TCP connection with a three-way handshake: SYN, SYN-ACK, ACK. The address usually belongs to a nearby CDN edge server.
  4. SYN-ACK The edge answers. After the browser's ACK the connection is open, one round trip later.
  5. TLS: hello, keys TLS 1.3 agrees encryption keys and proves the server owns the name, using its certificate. One more round trip.
  6. GET /cart Now the real request goes out: method, path, headers and cookies, all encrypted.
  7. Not cached: forward A personal page like a cart cannot be cached at the edge, so the CDN forwards the request over a fast, already-open connection to the origin.
  8. auth, business logic A load balancer picks an app server. It checks the session, applies the business rules and decides what data it needs.
  9. SELECT cart items The app reads the cart from a cache or database, usually in the same data center, well under a millisecond away on the network.
  10. rows The data comes back and the app builds an HTML or JSON response.
  11. 200 OK + HTML The response travels back to the edge, which passes it on to the browser.
  12. 200 OK + HTML The first byte arrives. Time to first byte is one of the main numbers teams watch.
  13. GET css, js, images The browser parses the HTML, finds dozens of assets and requests them over the same connection. These are cacheable, so the edge answers directly.
  14. render the page The browser builds the layout, runs scripts and paints. The page becomes usable.

Three things stand out. First, several round trips happen before the request is even sent: DNS, TCP and TLS. That is why reusing connections and moving servers closer to users matter so much. Second, the CDN is the first stop, not the app: most bytes of most pages never reach your servers. Third, the database is only one hop out of many, even though it is where most design discussions focus.

Step 4: Where it can fail

Each hop has its own failure modes, and part of design is deciding what the user sees when one breaks:

Places where a page load can fail A tree with the root Page does not load and five branches: DNS failures, network failures, TLS failures such as an expired certificate, server errors, and database problems. DNS name not found Network loss, timeouts TLS expired cert Server 5xx errors Database slow or down Page does not load Figure 2. One symptom, many causes. Expired certificates and DNS mistakes are classic causes of whole-site outages.

Try it

Where can this hop be cached?

  1. Browser cache Static files with long cache headers are reused without any network request at all. Zero milliseconds.
  2. DNS caches The browser, the operating system and the resolver all keep DNS answers for their time to live, so most visits skip the full DNS walk.
  3. Connection reuse A connection opened once is kept alive and reused for later requests, skipping the TCP and TLS round trips.
  4. CDN edge cache Images, scripts, styles and even whole public pages are served from a city near the user, never touching your servers.
  5. Application cache The app keeps popular results, such as a product page, in an in-memory cache like Redis instead of asking the database each time.
  6. Database buffer cache Even the database keeps hot pages of data in memory, so many reads never touch the disk.

Try this:

  1. For each step, estimate how many milliseconds it saves compared with not caching. Which saves the most?
  2. Which layers cannot help with a personal page like a shopping cart, and why?
  3. Pick one cache and think about what happens when the data it holds changes. You will return to this in the caching module.

Going deeper

Second visits are much faster

On a repeat visit, DNS is cached, the connection may still be open, and static files come from the browser cache. Only the personal parts of the page travel all the way to the origin. That is why first-visit performance and repeat-visit performance are measured separately.

Every hop gets its own lesson

DNS is covered in DNS in depth , TCP and packets in Networking basics: IP, TCP, UDP and ports , TLS in TLS and HTTPS and HTTP versions in HTTP/1.1, HTTP/2 and HTTP/3 . The orders of magnitude in the margin come from Latency numbers every engineer should know .

Trade-offs

OptionWins whenLoses when
Serve from a CDN edge Static and public content: fast for everyone, offloads your servers Personal or rapidly changing content that must not be shared or go stale
Keep connections open Many requests from the same client: skips handshakes Servers with limited memory facing many idle clients
Long cache lifetimes Files that never change, such as versioned assets Content that must update immediately for everyone

Common mistakes

  • Thinking a page load is one request. A typical page makes dozens of requests, and the slowest critical one sets the pace.
  • Ignoring the handshakes. On a mobile network, DNS, TCP and TLS can cost more than the server's own work.
  • Blaming the database first. Measure each hop; slow pages are often slow in the network or the browser.
  • Forgetting certificates expire. Automate renewal, or one forgotten date takes the whole site down.

Check yourself

  1. What does the browser need before it can open a connection to shop.example.com?

    Show answer

    B. An IP address, from DNS or its cache Connections go to IP addresses, so the hostname must be resolved first, unless the answer is already cached.

  2. On a first visit, roughly how many round trips happen before the HTTP request is sent, after DNS?

    Show answer

    B. About two: TCP then TLS 1.3 The TCP handshake takes one round trip and TLS 1.3 another, so the request goes out after about two.

  3. Why can't a CDN usually cache your shopping cart page?

    Show answer

    B. It is personal to you and changes often Shared caches must not serve one user's private data to another, so personal pages go to the origin.

  4. Which hop is most often answered without reaching your servers?

    Show answer

    A. Requests for static assets like images and scripts Static assets are cacheable, so the browser cache or the CDN edge answers them.

Recap

  • A page load is many hops: caches, DNS, TCP, TLS, HTTP, CDN, app servers and data stores.
  • Several round trips happen before the request is even sent, so distance and connection reuse matter.
  • Most bytes are served by caches and CDNs; only personal content reaches the origin.
  • Every hop adds latency, can be cached and can fail.
  • Later lessons zoom into each hop on this map.

Get new lessons by email

Get new posts on backend and AI internals. No spam, unsubscribe anytime.

Your email is only used to send new posts. Privacy

Next up