TCP Handshakes: Establishing a new TCP connection for each HTTP request involves a three-way handshake, which introduces latency and consumes additional resources. By using keepalive, TCP connections can be reused for multiple requests, minimizing the handshake overhead.
TLS/SSL Handshakes: For HTTPS connections, the handshake process is even more resource-intensive due to the cryptographic operations required. Keepalive allows the reuse of TLS/SSL sessions, significantly reducing the computational overhead and latency associated with establishing secure connections.
Faster Resource Loading: Reusing connections allows subsequent HTTP requests to bypass the connection establishment phase, resulting in faster loading times for web pages, especially those with numerous resources (images, scripts, stylesheets, etc.).
Persistent Connections: HTTP/1.1 and HTTP/2 support persistent connections, which are effectively utilized through keepalive, allowing multiple requests and responses to be sent over the same connection without waiting for each to complete in turn.
Reduced Server Load: By maintaining a pool of open connections, the reverse-proxy can more efficiently manage its connections to backend servers, leading to reduced CPU and memory usage associated with opening and closing connections.
Connection Pooling: The keepalive feature allows the reverse-porxy to maintain a pool of connections that can be reused for different requests, enhancing the utilization of server resources and improving the capacity to handle high loads.
Reduced Network Congestion: Minimizing the number of new connections reduces the overall volume of TCP and TLS handshake data on the network, contributing to less congestion and better utilization of available network bandwidth.
On the backends section click on the little button “Keep alive [OFF]"
Connections: Specifies the number of idle keepalive connections to backends that remain open for each worker process. If 0, then the Keep Alive feature is disabled.
Max requests: This option defines the maximum number of requests that can be sent over a single keep alive connection before the connection is closed by the reverse-proxy. Limiting the number of requests per connection can help in mitigating potential performance degradation over time and managing reverse-proxy resources more effectively.
TTL: Limits the maximum of time requests can be processed by a single connection. Once this time limit has been reached, the connection is closed after the next request has been processed.
Timeout: This option specifies the maximum time (in seconds ) that a keep alive (persistent) connection will remain open after passing a request to the backend but without receiving another request. Once this timeout expires, the reverse-proxy closes the connection. This parameter can help manage reverse-proxy resources by limiting how long idle connections stay open.