Web Server Tuning

The web server also needs tuning before going into production. The configuration that comes with the Apache distribution (or with our OS software package) is normally not optimised for high load web sites and thus, you need to tweak it. Especially the mpm_common worker module is important to configure for production use. Be sure to read and understand the documentation for this module and then continue to these more general Apache performance guides:

Be sure not to use the prefork MPM worker, but the (today normal) multi threaded worker.

The Apache worker is set during compile time. Thus, if you have compiled it from source, check your build (configure) options to be sure the multi threaded worker is selected. If you have installed Apache from RPM/DEB packages, you typically can use rpm -qa | grep apache or dpkg -l "*apache*mpm" to see make sure the high speed worker is being used.

This is an example of configuring the Apache worker for production use.

# worker MPM
<IfModule worker.c>
# We could increase ServerLimit to 64 and ThreadLimit/MaxClients to 8192,
# but be aware of the OOM of Death!!

# initial number of server processes to start
# http://httpd.apache.org/docs/2.2/mod/mpm_common.html#startservers
StartServers         3
ServerLimit          32

# minimum number of worker threads which are kept spare
# http://httpd.apache.org/docs/2.2/mod/mpm_common.html#minsparethreads
MinSpareThreads     512

# maximum number of worker threads which are kept spare
 http://httpd.apache.org/docs/2.2/mod/mpm_common.html#maxsparethreads
MaxSpareThreads     1024

# upper limit on the configurable number of threads per child process
# http://httpd.apache.org/docs/2.2/mod/mpm_common.html#threadlimit
ThreadLimit         4096

# maximum number of simultaneous client connections
# http://httpd.apache.org/docs/2.2/mod/mpm_common.html#maxclients
MaxClients         4096

# number of worker threads created by each child process
# http://httpd.apache.org/docs/2.2/mod/mpm_common.html#threadsperchild
ThreadsPerChild     128

# maximum number of requests a server process serves
# http://httpd.apache.org/docs/2.2/mod/mpm_common.html#maxrequestsperchild
MaxRequestsPerChild  10000
</IfModule>
      

Furthermore, we suggest that you have a good understanding of the following parameters. The values given here are suggestions that work well in production sites today. However, your needs may be different and you should therefore, as always, take heed when choosing (and sticking to) a number:

MaxKeepAliveRequests 1000
KeepAliveTimeout 5