Web Server Tuning
Your web server needs to be tuned before going into production. The standard configuration included with the Apache distribution (or with our OS software package) is not optimised for high load web sites and you will therefore need to modify it. It is particularly important to configure the mpm_common worker module for production use. Be sure to read and understand the documentation for this module and then continue to these more general Apache performance guides:
Do not use the prefork MPM worker, use the multi-threaded worker instead.
The Apache worker is set at 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 can usually use
rpm -qa | grep -i apache
or dpkg -l
"*apache*mpm"
to make sure that the high speed worker is
being used.
This example shows how to configure 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>
Make sure that you have a good understanding of the
MaxKeepAliveRequests
and
KeepAliveTimeout
parameters. The following values:
MaxKeepAliveRequests 1000 KeepAliveTimeout 5
work well in many production sites today. However, your needs may be different and you should therefore be careful when setting these parameters.