Overview

The default configuration for the Apache Web Server provides a set of safe options to enable Apache to perform well in a lightly loaded environment. One key parameter is “Keepalive” which is normally off.  For a content rich site where multiple connections are made from a client to retrieve lots of content, the Apache web server will perform additional work to process additional open/close requests for each request from the same client. By using KeepAlive a 50% reduction in connection time can be achieved when HTTP/1.1 requests are performed by the client browser. To assist with the increased workload that will result from keep alives being enabled, the number of worker processes can be increased in the configuration file to enable quicker response when more requests are being received.

Implementation    

The Apache config file is called httpd.conf and usually resides in /etc/httpd/conf/ on most Linux Distributions.

Prior to any changes make a backup copy of your configuration file. For example, I used a date-time notation to keep a copy of the file.

cp httpd.conf 2014-04-28-1149-httpd.conf

Open the file using "vi" and edit the following values:

KeepAlive “On”
KeepAliveTimeout 30
MaxKeepAliveRequests 1000
StartServers 10
MinSpareServers 10
MaxSpareServers 50
ServerLimit 100
Maxclients 100
MaxRequestsPerChild 4000

Outcome    

In initial testing there was a marginal increase in response times but this was not consistent as all connections were coming from the same test server and the gains from the KeepAlive setting are small but significant when a large number of connections are being made from different clients. Tuning per site is recommended as memory consumption will be an issue more than performance timing.

For specific details on each directive for Apache 2.4 (Change to 2.2 for Apache 2.2 systems), see: https://httpd.apache.org/docs/2.4/mod/core.html  

Was this article helpful?

Related Articles