In this lesson · topic 1 of 7
Topic 1
The cost before the first byte
3 min read
A request is not the first thing sent
Before a client can send a request over TCP with encryption, two things happen. TCP sets up the connection, which takes one round trip. TLS then agrees on keys, which takes one more with TLS 1.3. The client can send its request only after both.
At a round trip of 50 ms that is 100 msmeasured before anything useful moves. The request and the reply then cost another round trip.
The lab sends 200 requests a second at a 50 ms round trip. With connections reused from a pool, the average request took 90 msmeasured. With a new connection for every request, it took 190 msmeasured. The handshake more than doubled the wait, and it bought nothing.
Two follow-up questions
If connections are reused, a client needs a pool, and a pool has a size. Too few connections and requests queue. This lesson shows how to size one.
If a connection is shared by many requests at once, as HTTP/2 does, a problem appears. One lost packet can stall every request on that connection. The later topics explain it and show what QUIC changes.
Predict first