Connection reuse is the process of using the same TCP connection to send and receive multiple HTTP requests and responses. Alternatively, a new connection is subsequently opened to handle each pair of new messages.
What makes connection reuse beneficial?
When clients first want to make a request, they first need to establish a connection, which can take a handful of milliseconds to complete. Frequently, these connections are secure and necessitate negotiating TLS, which takes additional time.
Since loading a web page, querying a database, and similar activities all involve multiple requests, we want to keep them over existing connections as much as possible. Doing so avoids the added delays from continually forming new connections.
Load balancers sit between clients and backend servers, meaning two connections are involved: one from the client to the load balancer and another from the load balancers to the backends. A client might need to request resources served from multiple different servers. Because of this, the load balancer independently keeps connections open to improve performance and reduce latency.
How does HAProxy help with connection reuse?
HAProxy lets clients keep connections open, so when a page is loaded or a user browses a website, they don’t need to make a new connection for each request. This is possible even when the client requests resources hosted on different backend servers (see content switching) that HAProxy sits in front of.
HAProxy will also keep a pool of connections open to backend servers and reuse them. Since some older web servers close connections unexpectedly (and since most connections between HAProxy and backends reside within the same network, and can be opened rapidly), it'll normally make new connections upon a client's first request. Plus, you can configure your settings to maintain a pool of connections open to backend servers and promote more aggressive reuse.