Skip to content

What Happens When You Open a Web Page: DNS, TCP, TLS, and HTTP

6 min reading

Outcome: Trace a browser request through name lookup, connection setup, encryption and an HTTP response; calculate where the waiting time goes.

Page details

System Design foundations · Chapter 1 · Sources

Published · Last edited: · ~6 min reading · ~17 min with practice

20px

Know first: No previous chapter required.

System Design foundations glossary

Hypothetical scenario. Northwind's catalogue loads slowly after a customer follows a marketing link. Dev sees a fast database query, but that query began after several network exchanges. A page request includes work before the application can answer it.

A name is not yet an address

A browser starts with a URL: a scheme such as HTTPS, a host name and a path. The host name is convenient for people; the network needs an address. DNS, the Domain Name System, translates names into records the client can use to find a destination. An answer may already be cached, or the resolver may need more communication before it can reply.

The destination address is not necessarily the machine holding the catalogue database. It may identify an edge service or load balancer that forwards traffic. Keep the distinction between naming a service and locating its current implementation. DNS helps the client find an endpoint; it does not decide which product price is authoritative.

Build the conversation before the question

For the TCP-based path considered here, the client establishes a connection. TCP provides an ordered byte stream. Its handshake exchanges information so both sides can manage that stream. A round-trip time, or RTT, is the elapsed time for a message to travel out and a response to return. An RTT includes the network path and waiting along it, not just physical distance.

HTTPS adds TLS, Transport Layer Security. TLS negotiates cryptographic protection and authenticates the server under the client's trust rules. Encryption protects the connection; it does not make an incorrect product description true or give the caller permission to change a price. The application still enforces its own contract and access rules.

DNSFind an addressTCPOpen a streamTLSProtect the streamHTTPAsk and answer
DNS: Find an address → TCP: Open a stream → TLS: Protect the stream → HTTP: Ask and answer. Illustrative conceptual flow.

Once the connection is ready, HTTP carries the request and response. A request identifies a method and target and can include headers and a body. The response includes a status code, headers and optionally content. A successful HTTP response means the server reported success according to that endpoint's semantics; an HTML page can still contain missing information or trigger additional requests.

Account for four waits

Illustrative calculation. Choose a DNS lookup of 20 milliseconds and a network RTT of 40 milliseconds. Assume a new TCP connection takes one RTT, a full TLS 1.3 handshake takes one further RTT, and sending the HTTP request and receiving the first response takes another RTT. This simplified sequential path costs 20 + 40 + 40 + 40 = 140 milliseconds, before adding server processing or response transfer time.

If server processing adds a chosen 10 milliseconds, the corresponding first-response budget becomes 140 + 10 = 150 milliseconds. Making that query twice as fast saves 5 milliseconds, producing 145 milliseconds. It does not remove the 140 milliseconds assigned to the earlier stages. Identify the largest contribution before choosing an optimization.

Now suppose the DNS answer is cached and an established secure connection is reusable. In this chosen model, the remaining request/response RTT plus server processing is 40 + 10 = 50 milliseconds. The 100-millisecond difference is a consequence of these assumptions, not a benchmark for every website. Connection reuse changes which steps are on the path.

Read the protocol promise

In the wild. RFC 8446 specifies TLS 1.3's handshake and distinguishes ordinary handshakes from early data. That distinction explains why “TLS takes one RTT” needs a stated connection scenario. Early data has replay considerations; a shorter handshake is not automatically appropriate for an action such as submitting an order.

HTTP status classes communicate different kinds of results: a 2xx code reports success, 3xx directs the client elsewhere, 4xx reports a client-side request problem, and 5xx reports a server-side problem. The individual code and endpoint contract matter. A redirect can add another exchange; a retry after a lost response can repeat an action whose outcome is unknown.

Do not blame every wait on the server

Misconception: a long page load proves the application server is slow. Name lookup, connection setup, network congestion, transfer size and follow-up resources can all contribute. Measure the stages separately. A fast first response also does not prove the entire page is ready; images, styles and scripts may arrive later.

Use this trace when turning “the site is slow” into a specific question. Ask whether the connection was new, whether DNS was cached, what the response code meant and which bytes the timer covered. Later lessons add load balancers and end-to-end budgets, but these boundaries already prevent an application-only explanation from hiding network work.

The numerical model deliberately excludes parallel resource loading, HTTP/3 over QUIC, TLS resumption, retransmissions and changing network conditions. Those are reasons to refine the trace for a measured deployment. They are not reasons to abandon the accounting: write down the actual steps and count only the waits that occur.

Check yourself

The query drops from 10 ms to 5 ms. Does the 150 ms budget halve?

No. In the stated model it becomes 145 ms. Only the server-processing contribution changed; the chosen DNS and network waits remain.

A second request uses an existing secure connection. Which costs disappear from this model?

The new DNS lookup, TCP handshake and TLS handshake are absent under the stated reuse assumptions. The HTTP exchange and application processing still take time.

TLS succeeds but an employee cannot edit prices. Is the connection broken?

No. TLS connection authentication and encryption are separate from application authorization. The service can correctly deny a price edit over a healthy secure connection.

Go deeper