Try
↑ ↓ move↵ openesc close
In this lesson · topic 1 of 7
  1. 1. The cost before the first byte
  2. 2. Handshakes and connection pools
  3. 3. Pool size, protocol and packet loss
  4. 4. A pool that is too small
  5. 5. HTTP/1.1 against HTTP/2
  6. 6. Head-of-line blocking and QUIC
  7. 7. Connections in review

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

A client opens a new TCP and TLS 1.3 connection for each request, with a 50 ms round trip. How much does the setup add to each request?

Your progress is saved in this browser. Sign in to keep it on every device. Privacy · Terms