The cost of new connections
Every new TCP connection pays for a handshake, and with TLS a second cryptographic handshake on top. That round trip cost adds latency to the first byte. Connection reuse amortizes that cost across many requests.
Keepalive
In HTTP, the keepalive mechanism keeps the underlying TCP connection open after a response so the next request can skip the handshake. A header controls how long an idle connection may stay open and how many requests it may serve.
- The first request pays the full setup cost.
- Subsequent requests on the same connection reuse it.
- An idle timeout eventually closes unused connections.
At the TCP layer a separate TCP keepalive probe detects dead peers by sending periodic empty segments. Clients also maintain connection pools so a fixed set of warm connections serves bursts of traffic without per request setup.
Key idea
Keeping connections warm and reusing them removes repeated handshake latency from most requests.