CoursesTCP to HTTPS, one request under a microscope
Puzzle 3 · 4 of 5
Where did the extra round trips go?
Time one small request over a new connection, then reuse the connection and account for the difference.
All puzzles in this course
The problem
A backend responds nearly instantly once it sees a request. The network takes 40 ms each way. Why can the first small response still take about a quarter of a second?
See it
Scroll sideways to see the full diagram.
Forty milliseconds there and forty back makes an 80 ms round trip.
Step 1 of 4The phone spends a round trip starting the TCP connection.
Step 2 of 4The full TLS 1.3 server flight takes another round trip.
Step 3 of 4The regular HTTP request and first response byte take a third under the model.
Step 4 of 4
The building block
A round trip is the time for a signal to go to the peer and back. With 40 ms each way, the RTT, or round-trip time, is 80 ms. HTTPS is HTTP over a secure connection. Here we trace HTTP over TCP with a full TLS 1.3 handshake. The phone still verifies the handshake transcript before its regular request.
| Step | Time on this simplified path |
|---|---|
| Send TCP SYN, get SYN-ACK | 1 RTT |
| Send the final acknowledgment with or alongside the TLS client hello, receive the TLS server flight | 1 RTT |
| Send client Finished and regular HTTP request, receive the first response byte | 1 RTT |
The estimate is about 240 ms. It assumes the address is known, the response is small, both sides respond immediately, no packets are lost, and the request has no early data, and the server accepts the initial key share without requesting a retry. It measures from the start of TCP establishment. It omits DNS, resource contention, redirects and other work real apps may do.
On a compatible connection that is already open, the setup is done. A small request can reach the server and return in roughly one RTT under the same assumptions. Time to first byte measures the wait until the response begins. A larger response can still take much longer to finish transferring.
Go deeperA real timing trace
A second request takes 155 ms. The network RTT is 80 ms and the measured server work is 70 ms. Is another TLS exchange required to explain the time?
No. Roughly 150 ms already comes from network travel plus server work. Check separately whether the client actually reused its connection before assigning the remaining time.
Check yourself
Sources
What you now know
A simplified fresh HTTPS request over TCP with full TLS 1.3 takes three RTTs to the first response byte. An already open connection can remove both setup exchanges.
Answer every question above correctly to unlock the next puzzle.
Something wrong or unclear on this page? Tell me: a puzzle that didn't click is a bug in the puzzle.