Skip to main content

Keep-Alive

Learning Focus

By the end of this lesson you will understand how HTTP keep-alive works, what settings to tune, and how to find the right balance for your traffic.

What Keep-Alive Does

Keep-alive allows multiple HTTP requests over a single TCP connection. Without it, the browser must open a new connection for every resource — each with a TCP handshake and potentially a TLS handshake.

Key Settings

SettingWhat It DoesRecommended Range
Keep-Alive TimeoutHow long to keep an idle connection open5-60 seconds
Max Keep-Alive RequestsMaximum requests per connection1000-10000

Tuning Guidelines

Server SizeTimeoutRationale
Small VPS (1-2 GB)5-15sConserve connections and file descriptors
Medium (4-8 GB)15-30sBalance reuse and capacity
Large (16+ GB)30-60sMaximize client connection reuse

Configuring in WebAdmin

  1. Server ConfigurationTuningConnection
  2. Set Keep-Alive Timeout and Max Keep-Alive Requests
  3. Save and Graceful Restart

Verifying

# Check keep-alive in response headers
curl -sI https://example.com | grep -i "keep-alive\|connection"

Key Takeaways

  • Keep-alive reduces handshake overhead by reusing connections for multiple assets.
  • Set timeouts high enough to help browsers, but not so high that idle clients waste capacity.
  • Modern browsers and HTTP/2 manage multiplexing automatically, but keep-alive remains valuable.

What's Next

  • Continue to HTTP/2 for modern protocol multiplexing.