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

Where did the extra round trips go? 80 ms per RTT TCP setup TLS setup First byte

Scroll sideways to see the full diagram.

  1. Forty milliseconds there and forty back makes an 80 ms round trip.

    Step 1 of 4
  2. The phone spends a round trip starting the TCP connection.

    Step 2 of 4
  3. The full TLS 1.3 server flight takes another round trip.

    Step 3 of 4
  4. The 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.

StepTime on this simplified path
Send TCP SYN, get SYN-ACK1 RTT
Send the final acknowledgment with or alongside the TLS client hello, receive the TLS server flight1 RTT
Send client Finished and regular HTTP request, receive the first response byte1 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.

Back to the main puzzle

Check yourself

On this model, the RTT rises to 100 ms. What is the approximate first-byte time over a fresh connection?

Not quite. The regular request still adds another trip. Re-read that part ↑

Right. Count dependencies before calculating time.

Not quite. The setup exchanges happen before the regular request. Re-read that part ↑

The app reuses the open connection. What is removed in this model?

Right. Reuse leaves the regular request and response trip.

Not quite. Both TCP and TLS are already ready on the reused connection. Re-read that part ↑

Not quite. A response still needs the return path. Re-read that part ↑

The first byte arrives at the same time, but a larger response finishes later. What changed?

Not quite. More bytes can take longer without changing round-trip time. Re-read that part ↑

Not quite. The comparison holds response start time fixed. Re-read that part ↑

Right. Distinguish the start of the response from its end.

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.