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 latency 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.
You’ve mastered one topic, but why stop there?
Our blog delivers the expert insights, industry analysis, and helpful tips you need to build resilient, high-performance services.
How does HAProxy help with connection reuse?
HAProxy lets clients keep connections open, so browsing a website doesn't require a new connection for every request, even when resources sit on different backend servers (see content switching). HAProxy also keeps a pool of backend server connections and reuses them — you can tune these settings to enable more aggressive reuse. Connection reuse is one of many important application acceleration features in HAProxy Enterprise load balancer.
Learn more by reading our blog on HTTP keep-alive, pipelining, multiplexing, and connection pooling.