Try
↑ ↓ move↵ openesc close

Connection pools and head-of-line blocking lab

Send requests over a pool of connections. Compare handshakes on every request with reuse, a pool that is too small, HTTP/1.1 with HTTP/2, and what packet loss does to streams that share one TCP connection and to QUIC.

tick 100 (1 tick = 10 ms)HTTP/2 over TCP, pool 450 ms round trip, 1% loss

Latency

completed
165
median
150 ms
99th percentile
350 ms
waiting for a connection
0

Latency counts from the moment a request arrives, so time spent waiting for a free connection and time spent in a handshake are both included.

Connections and loss

connections opened
4
requests in flight
35
loss events
27
held by another stream's loss
56%

On TCP, one lost packet holds back every stream on that connection until the retransmit arrives. The share below is requests that finished late because of someone else's loss.

Mean latency of requests finishing each tick, and queue length, last 150 ticks
Mean latency of requests finishing each tick, and queue length, last 150 ticks. Text version available below the chart.0125250375500151100recent ticksms or requests

What to try

Each one sets up a starting point. Then make the change it describes.

  1. A handshake for every request

    Switch to a new connection per request, with HTTP/2 and no packet loss.

    Look for. Every request now waits for the TCP and TLS handshakes, two round trips, before it sends anything. Median latency roughly doubles at this round trip time, and the number of connections opened explodes.

  2. A pool that is too small

    Choose HTTP/1.1, no loss, and a pool of 8 connections.

    Look for. Each connection serves one request at a time, so 8 connections cannot keep up with 200 requests a second. Requests queue and latency grows without bound. A pool near 24 is enough.

  3. Multiplexing removes the queue

    Choose HTTP/2 with no loss and a pool of 4.

    Look for. Four connections carry all the requests at once, because streams share them. The queue is empty and latency is one round trip plus the work.

  4. One loss stalls everyone

    Choose HTTP/2 with a pool of 1 and 2 percent loss.

    Look for. A lost packet holds back every stream on the connection until the retransmit lands. Most requests finish late because of loss on a different stream. The 99th percentile climbs by an order of magnitude.

  5. The same loss over QUIC

    Keep the pool at 1 and 2 percent loss, and choose HTTP/3.

    Look for. Only the stream that lost the packet waits. Other streams keep going, and no request is held back by someone else's loss.

New to the idea? Read the lesson first. Every number here comes from a seeded simulator, so the same seed gives the same run.

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