How a request travels
What breaks
Section titled “What breaks”You built the salon page from lesson 0.3. On your laptop, on the office network, it opens before you lift your finger. The server logs say each request takes 30 ms. It works.
Then a customer taps the link in a WhatsApp message, on a phone, on a mobile network. She waits. The page is blank for close to two seconds, then the salon’s name appears, then the photos. The server log for her visit still says 30 ms.
So where did the time go? Not into the server. It went into the trips between her phone and your server, before and after the 30 ms of work.
Count them. The page is built in the browser: the server sends a short HTML page, the HTML loads a script, and the script calls your API, on a second host name, for the salon’s details. For a phone that has never visited before, the first request costs one round trip to look up the name, one to open a connection, two to agree on encryption, and one for the request itself: five. The script reuses that connection: one more. The API is a new host name, so it pays the same five again. Eleven round trips before the salon’s name can appear.
Google’s Lighthouse tool tests mobile pages with a round-trip time of 150 ms, a figure it says represents “roughly the bottom 25% of 4G connections and top 25% of 3G connections” (checked 2026-11-29). Eleven × 150 ms is 1.65 seconds. On your laptop, Lighthouse’s desktop figure is 40 ms: eleven × 40 ms is 440 ms, which is why you did not see it. And that is before the bytes. A 500 KB script at Lighthouse’s 1.6 Mbps is 4,000 kilobits ÷ 1,600 kilobits a second: 2.5 seconds on its own.
What broke? You measured the part you control and ignored the trip. A request is not one event. It is a stack of small conversations, and each one costs round trips. This lesson walks that stack one layer at a time and counts what each layer costs.
Terms used in this lesson:
- A round trip is one message out and its answer back. Round-trip time (RTT) is how long that takes. Lesson 0.3’s table put one inside a data centre at 0.5 ms and one across an ocean at 150 ms.
- DNS (Domain Name System) turns a name such as a salon’s address into an IP address. A resolver is the server that does the lookup for your phone and keeps answers in a cache.
- A packet is one unit of data the network carries. IP (Internet Protocol) moves packets from one address to another.
- TCP and UDP are transports: they carry data between two programs on top of IP. TCP is reliable and ordered; UDP is not.
- A handshake is the set of messages two sides exchange before real data can flow.
- TLS (Transport Layer Security) encrypts the connection and proves the server is who it says it is, using a certificate.
- HTTP is the request and response a browser and a server speak: “GET this page”, “here it is”.
- Head-of-line blocking is when one stuck item holds up everything queued behind it.
- QUIC is a newer transport that runs on UDP and builds reliability and TLS into itself. HTTP/3 runs on QUIC.
Mental model
Section titled “Mental model”A request is a stack of handshakes, and every handshake costs round trips. The name becomes an address (DNS). The address gets a path (IP). The path becomes a pipe (TCP, or QUIC on UDP). The pipe gets a lock (TLS). Only then does the conversation start (HTTP). On a phone, the time a page takes is roughly the number of round trips × the RTT, plus the bytes ÷ the bandwidth. In the salon example, server time was the smallest term.
So the question for every design choice in this lesson is the same: how many round trips does it remove, and what does it cost?
Diagram
Section titled “Diagram”A phone opening the salon page for the first time, over HTTP/2, TCP and TLS 1.3. Each numbered note is one round trip.
The ACK and the client’s Finished travel with the next message out, so they add no round trip of their own. With TLS 1.2, round trip 3 becomes two. With HTTP/3, rounds 2 and 3 become one.
Walking the salon request through the layers
Section titled “Walking the salon request through the layers”DNS: the name becomes an address. The phone asks its resolver for the address behind the salon’s host name. DNS queries go over UDP, port 53. Why UDP? RFC 1035 calls it “the recommended method for standard queries”: a question and its answer each fit in one message (originally “restricted to 512 bytes”), so there is nothing to set up. The cost is that “queries sent using UDP may be lost, and hence a retransmission strategy is required” — the resolver simply asks again. DNS also runs over TCP, for answers too big for one message; RFC 7766 says every general-purpose implementation “MUST support both UDP and TCP”.
Every answer carries a TTL (time to live): in RFC 1034’s words, it “describes how long a RR can be cached before it should be discarded”. A cached answer costs no round trip. That is why the first visit is slower than the second. If the resolver itself has no cached answer, it asks other DNS servers in turn, which costs more round trips that this lesson does not count.
IP: the address gets a path. IP’s job, from RFC 791, is to “deliver a package of bits (an internet datagram) from a source to a destination over an interconnected system of networks”. Note what it does not do: “There are no mechanisms to augment end-to-end data reliability, flow control, sequencing”. Packets can be lost, duplicated or arrive out of order. An IPv4 address is 32 bits; IPv6 “increases the IP address size from 32 bits to 128 bits”. Everything above IP exists because IP promises so little.
TCP or UDP: the path becomes a pipe. Two choices sit on top of IP. UDP adds almost nothing: RFC 768 describes “a minimum of protocol mechanism” where “delivery and duplicate protection are not guaranteed”. TCP adds a lot: “a reliable, in-order, byte-stream service”. It resends what is lost and puts bytes back in order. The price is the three-way handshake before any data flows, which RFC 7413 says “adds one RTT to network latency”. A web page needs every byte, in order, so the web has run on TCP.
TLS: the pipe gets a lock. Before HTTP sends anything, TLS agrees on keys and the server shows a certificate. Up to TLS 1.2, RFC 7918 says, a full handshake “requires two full protocol rounds … Thus, using TLS can add a latency penalty of two network round-trip times”. TLS 1.3 cut that to one: in the 1-RTT handshake, as RFC 9001 puts it, “the client is able to send application data after one round trip”.
One more detail matters for the salon page. Many host names can share one server and one IP address, so how does the server know which certificate to show before any HTTP arrives? The phone tells it. The Server Name Indication (SNI) extension puts the host name in the first TLS message, because plain TLS “does not provide a mechanism for a client to tell a server the name of the server it is contacting”.
HTTP: the conversation. Now the phone sends GET /. The host name travels again, in the Host
header in HTTP/1.1, or the :authority field in HTTP/2 and HTTP/3. RFC 9110 says why: it lets the
server “distinguish among resources while servicing requests for multiple host names”. The server
does its 30 ms of work and answers.
Counting round trips
Section titled “Counting round trips”Cold means a phone that has nothing cached. The count is round trips before the first byte of the response, so the server’s own time comes on top.
| Stack | DNS | Connect | Encrypt | Request | Total | At 150 ms |
|---|---|---|---|---|---|---|
| HTTP/1.1 or HTTP/2, TCP, TLS 1.2, cold | 1 | 1 | 2 | 1 | 5 | 750 ms |
| HTTP/1.1 or HTTP/2, TCP, TLS 1.3, cold | 1 | 1 | 1 | 1 | 4 | 600 ms |
| HTTP/3, QUIC, cold | 1 | 1 (with TLS) | — | 1 | 3 | 450 ms |
| HTTP/3, QUIC, returning visit, DNS cached, 0-RTT | 0 | 0 | 0 | 1 | 1 | 150 ms |
Why does HTTP/3 save a round trip? RFC 9000: “The QUIC handshake combines negotiation of cryptographic and transport parameters.” Connect and encrypt happen in the same messages.
What is the last row? TLS 1.3 added “a zero round-trip time (0-RTT) mode … saving a round trip at connection setup for some application data, at the cost of certain security properties”. A phone that has talked to this server before can send its request in its very first message. The cost is in the trade-offs below.
Now go back to the opening. The browser-built page paid for two cold connections plus a script. If the server builds the page instead, the phone pays one cold connection, four or five round trips, and the server’s call to the API happens inside the data centre, where lesson 0.3’s table puts a round trip at 0.5 ms. The data and the server are the same; the waiting is about half.
Real case
Section titled “Real case”Roost is a booking platform for businesses that sell their time, such as salons and studios. Its public booking page meets this exact request.
The problem. Customers reach a business’s booking page from a link shared in a chat message, often WhatsApp, on a phone, with no account. The page has to be useful on a slow mobile network, and the project’s own target assumes 3G. It also has to serve many businesses, each with its own address, without a setup step per business.
The design. Each business gets its own host name under one platform domain. A single wildcard
DNS record answers for all of them. RFC 4592 describes wildcard records as “instructions for
synthesizing” answers, so a new business needs no DNS change at all. Every name leads to the same
app, and the app reads the host name from the request to decide which business to show: the job
RFC 9110 gives the Host header. The business’s landing page is built on the server, so the first
response already carries the salon’s name and services. The booking steps that follow run in the
browser.
The trade-off. Server-rendering moves work from the phone to the server, and keeps the API call off the slow link, as the round-trip count showed. The cost is server time on every page view. Lessons 1.8 (server rendering) and 2.4 (caching) are about paying that cost well. The wildcard name means every business shares one deployment, so one bad release reaches all of them at once.
Honest about scale. Roost is early-stage. This lesson has no traffic or latency measurements from it; the round-trip arithmetic above is an estimate, not a measurement. At larger scale the next questions would be where the server sits relative to customers, and what sits between them, which lessons 1.2 and 3.8 take up.
Trade-offs
Section titled “Trade-offs”TCP against UDP. TCP gives every byte, in order, and costs a handshake. UDP gives no promise and costs nothing up front. Which do you choose? Ask what a lost message costs. DNS picks UDP because a lost query is cheap to ask again. A web page picked TCP because a missing byte breaks the page. QUIC shows the third option: build only the reliability you need, on top of UDP, so it can recover per stream. The cost of building on UDP is that some networks block it; RFC 9114 says clients “SHOULD attempt to use TCP-based versions of HTTP in this case”. So HTTP/3 never replaces the TCP path. It runs beside it.
HTTP/1.1 against HTTP/2 against HTTP/3. The salon page needs one HTML page and twenty photos. How does each version carry them?
- HTTP/1.1 keeps the connection open for the next request (“persistent connections”), but on one connection a response must finish before the next starts; even pipelined requests must be answered “in the same order that the requests were received”. So, RFC 9113 says, “HTTP/1.0 and HTTP/1.1 clients use multiple connections”. Each one pays its own TCP and TLS handshake, and RFC 9114 adds that this harms “congestion control and network efficiency”.
- HTTP/2 puts every request on one connection as its own stream, interleaved, with compressed headers. One handshake, twenty photos. The cost, in RFC 9113’s own words: “TCP head-of-line blocking is not addressed by this protocol.” TCP sees one byte stream, so when one packet is lost, RFC 9114 says, “all active transactions … experience a stall”. On a lossy mobile network, one lost packet of photo 3 holds up photos 4 to 20.
- HTTP/3 keeps streams but moves them into QUIC, which recovers loss per stream. A lost packet
stalls only its own photo. It also saves a round trip at connect time. And because a TCP
connection “is defined by a pair of sockets” (address plus port at each end), a phone that moves
from Wi-Fi to mobile data has to start again. QUIC’s “connection migration uses connection
identifiers to allow connections to transfer to a new network path”. The cost: UDP can be
blocked. And one way a client learns that a server speaks HTTP/3 is an
Alt-Svcheader on an earlier TCP response; when that is the only way, the first visit is not HTTP/3 at all. A DNS HTTPS record (RFC 9460) can announce it earlier.
How common is each? On Cloudflare’s network in 2025, “50% of requests … were made over HTTP/2”, “HTTP/1.x accounted for 29%” and “the remaining 21% were made via HTTP/3” (data to 2 December 2025, checked 2026-11-29). That is one network’s traffic, not the whole web, and it changes.
0-RTT against safety. 0-RTT saves a full round trip on a returning visit. RFC 8446 states the cost plainly: “There are no guarantees of non-replay between connections.” Someone who captures the first message can send it again. So RFC 8470 says clients “MUST NOT send unsafe methods” in early data. Loading the salon page is safe to repeat. “Confirm my booking” is not. Turn 0-RTT on for reads, and never let a write ride in it; lesson 2.6 covers what makes a repeated write safe.
Long DNS TTL against short. A long TTL means fewer lookups and fewer round trips. A short one means a change of address spreads quickly. RFC 1034 suggests TTLs “on the order of days for the typical host”, and lowering the TTL before a planned change, then raising it again. The cost of a long TTL is that an unplanned move leaves some phones at the old address until their cache expires.
A host name per tenant against a path per tenant. A tenant is one customer business on a
shared platform. Give each its own host name and you need a wildcard DNS record and
a certificate that covers every name. RFC 9525 limits a wildcard certificate to “the complete
left-most label”, and it “can only match one label”: it covers salon.example.com but not
booking.salon.example.com. Put tenants in the path instead (example.com/salon) and one name and
one certificate do. Why pay for host names, then? Browsers group pages into origins, and two
addresses share one “if they have the same scheme, host, and port”. Separate host names keep
tenants’ cookies and storage apart; a shared one does not. The path is simpler; the host name gives
each tenant its own origin.
Drill 1 — interview question
Section titled “Drill 1 — interview question”“A customer taps a link to a salon’s booking page on her phone. Walk me through everything that happens until she sees the page. Then tell me roughly how long it takes on a mobile network.”
Model answer
The layers, in order. The browser needs an address for the host name, so it asks its DNS
resolver, over UDP. The answer comes back with a TTL, and the phone caches it. Using that IP
address, the phone opens a TCP connection with the three-way handshake. Over TCP it runs a TLS
handshake: it sends the host name (SNI), the server picks the matching certificate, they agree on
keys. Then it sends GET / with the host name in Host or :authority, so the server knows which
salon. The server builds the page and replies. The browser then fetches the photos and scripts,
over the same connection if it is HTTP/2 or HTTP/3.
The time. Count round trips for a first visit: DNS 1, TCP 1, TLS 1 (TLS 1.3) or 2 (TLS 1.2), HTTP 1. Four or five. Assume 150 ms a round trip, Lighthouse’s figure for a slow mobile connection: 600 to 750 ms before the first byte, plus the server’s own time, plus download time for the bytes. The server’s 30 ms is the smallest term.
What I would change. TLS 1.3, HTTP/2 or HTTP/3 so the photos share one connection, the page built on the server so the API call does not cross the slow link, and fewer host names, since each new one pays the whole count again.
Rubric
- Names DNS, TCP (or QUIC), TLS and HTTP in the right order — 2
- Says what each adds: address, reliable pipe, encryption and identity, the request — 2
- Mentions how the server knows which site (SNI or Host) — 2
- Counts round trips and turns them into time with a stated RTT — 2
- Proposes at least one change that removes round trips, with its cost — 2
Total 10. 8 or more is a pass.
Drill 2 — interview question
Section titled “Drill 2 — interview question”The interviewer follows up: “You said HTTP/2 already puts all requests on one connection. So why did anyone build HTTP/3? And if UDP is unreliable, why would you run the web on it?”
Model answer
What HTTP/2 left broken. HTTP/2 fixed head-of-line blocking at the HTTP layer: twenty photos are twenty streams on one connection. But TCP underneath sees one stream of bytes. When one packet is lost, TCP holds back everything after it until the lost packet is resent, so every stream stalls, including the photos that lost nothing. On a lossy mobile network that happens often.
Why UDP. QUIC needs reliability, but per stream, not for the whole connection. UDP is almost empty, so QUIC can build its own reliability, ordering and congestion control on top, and recover each stream on its own. It also combines the transport and TLS 1.3 handshakes, saving a round trip, and its connection IDs let a phone keep the connection when it switches network.
The cost. Some networks block UDP, so clients fall back to TCP. A client may only learn about
HTTP/3 from an Alt-Svc header on an earlier response, so the first visit may still be HTTP/2. I would serve both, and
treat HTTP/3 as a gain on poor networks, not a replacement.
Rubric
- States that HTTP/2 multiplexes but still suffers TCP head-of-line blocking on loss — 2
- Explains why UDP: reliability built per stream in QUIC, not absent — 2
- Names the handshake saving (transport and TLS combined) — 2
- Names connection migration or another mobile benefit — 2
- Names a cost: UDP blocked and TCP fallback, or discovery on first visit — 2
Total 10. 8 or more is a pass.
Drill 3 — hands-on exercise
Section titled “Drill 3 — hands-on exercise”Measure the layers on a real request with curl, which can report when each step finished.
- Pick a public HTTPS site you are allowed to test. Run:
curl -o /dev/null -s -w 'dns %{time_namelookup}\ntcp %{time_connect}\ntls %{time_appconnect}\nfirst byte %{time_starttransfer}\n' https://<site>/Each number is seconds from the start, so the gaps between them are the layers. - Run it five times. Is the DNS figure smaller after the first run? Why? (Think TTL and caches.)
- Work out the TCP figure minus the DNS figure. That gap is about one round trip. Is the TLS gap
about one or about two times that? What does that tell you about the TLS version? Check by
adding
--tls-max 1.2. - Compare
--http1.1,--http2and, if your curl supports it,--http3. curl falls back to an earlier version if HTTP/3 fails, so check which version you got (add%{http_version}to the-wstring). - Repeat from a phone hotspot. Fill in the round-trip table from this lesson with your own RTT, and write one sentence on which layer cost the most.
Exit test
Section titled “Exit test”Answer without notes.
- Name the layers a page request passes through, in order, and say in one line what each adds.
- A phone has nothing cached and an RTT of 100 ms. How long until the first byte with TCP and TLS 1.2? With TLS 1.3? With HTTP/3? Show the round-trip count.
- Why do DNS queries use UDP? Why does HTTP/3 use UDP, when the web needs reliable delivery?
- Twenty photos are loading over HTTP/2 on a lossy network and one packet is lost. What happens to the other photos? What changes with HTTP/3?
- One server hosts 50,000 salons, each on its own host name. How does the server know which salon a request is for, at the TLS step and at the HTTP step? What does DNS need so a new salon needs no setup?
Further reading
Section titled “Further reading”- RFC 9293, Transmission Control Protocol — https://www.rfc-editor.org/rfc/rfc9293, and RFC 768, User Datagram Protocol — https://www.rfc-editor.org/rfc/rfc768. TCP’s promises and UDP’s lack of them.
- RFC 1034 and RFC 1035, Domain Names — https://www.rfc-editor.org/rfc/rfc1034, https://www.rfc-editor.org/rfc/rfc1035. TTLs, caching and UDP queries. RFC 4592 on wildcards — https://www.rfc-editor.org/rfc/rfc4592.
- RFC 8446, TLS 1.3 — https://www.rfc-editor.org/rfc/rfc8446, sections 1.2 and 2. The handshake and 0-RTT. RFC 7918 for the TLS 1.2 round-trip count — https://www.rfc-editor.org/rfc/rfc7918. RFC 8470 on early data in HTTP — https://www.rfc-editor.org/rfc/rfc8470.
- RFC 9110, HTTP Semantics, section 7.2 on
Host— https://www.rfc-editor.org/rfc/rfc9110. - RFC 9113, HTTP/2, section 1 — https://www.rfc-editor.org/rfc/rfc9113, and RFC 9114, HTTP/3, section 1 — https://www.rfc-editor.org/rfc/rfc9114. Each version explains what the previous one left broken.
- RFC 9000, QUIC, section 1 — https://www.rfc-editor.org/rfc/rfc9000. Combined handshake and connection migration.
- RFC 6066 section 3 (SNI) — https://www.rfc-editor.org/rfc/rfc6066, and RFC 9525 section 6.3 (wildcard certificates) — https://www.rfc-editor.org/rfc/rfc9525.
- Lighthouse, Network throttling — https://github.com/GoogleChrome/lighthouse/blob/main/docs/throttling.md. The 150 ms mobile figure; checked 2026-11-29.
- Cloudflare, 2025 Radar Year in Review — https://blog.cloudflare.com/radar-2025-year-in-review. HTTP version shares on one large network; dated 2025.
- curl manual,
--write-out— https://curl.se/docs/manpage.html. The timings used in the exercise.