I'm using Varnish as a frontend with Apache 2 as backend on my web server. What are the pros and cons of Apache's KeepAlive in this setting?

Apache and Varnish run on the same server now, but I could put them on different servers in the future.

1 Answer 1



  • TCP handshake between Varnish and Apache not needed for every single request, reducing overhead.


  • If your Varnish service wanted to DoS your Apache service with connection exhaustion, it's easier for it to do so..?

Can you clarify what's prompting this question? HTTP connection keep-alive is implied in HTTP 1.1 and on by default in every major web server for a good reason; it's a performance improvement (though it will be a very small one with no latency between services), with a couple of denial-of-service-related caveats that aren't applicable when Apache's only client is Varnish.

I'd even recommend increasing Apache's KeepAliveTimeout higher than the default of 5 seconds, to let Varnish continue to re-use the same pool of connections.

  • When using Apache as a regular frontend server, it is sometimes recommended to disable KeepAlive: "If your mod_perl server's httpd.conf includes the following directives: ... KeepAlive On ... you have a real performance penalty, since after completing the processing for each request, the process will wait for KeepAliveTimeout seconds before closing the connection and will therefore not be serving other requests during this time. With this configuration you will need many more concurrent processes on a server with high traffic." perl.apache.org/docs/1.0/guide/performance.html#KeepAlive Feb 26, 2012 at 11:22
  • 3
    That document is incredibly misleading and outdated, and should be stricken from the internet. It's assuming that the only limiting factor for "performance" is the number of spare available worker threads - which is rarely the case, and especially won't be the case when the only client is the Varnish server. They're also making that recommendation on the assumption that a given client will only be making one request at a time to the mod_perl server. And ignore the part about a client only using one connection, and taking longer because of it; that hasn't been the case for years. Feb 26, 2012 at 20:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .