Our Apache2 config changes for Drupal web server

Posted June 17th, 2011 by bryanr

Drupal is the tool of choice for our web site team, but it using alot of dynamic page content.  Consequently, that increases the memory usage for the apache server processes.  Each process on our production server uses 30-50MB.  The server currently has 4GB total memory, so that means it should be able to handle 80-130 web connections without swapping to disk.  This simple calculation is something that should be done for every web server to set the MaxClients limit.  Here are some other settings that we are using for Apache2 on our Drupal servers:

Timeout 30

KeepAlive On

MaxKeepAliveRequests 100

KeepAliveTimeout 5

# prefork MPM
# StartServers: number of server processes to start
# MinSpareServers: minimum number of server processes which are kept spare
# MaxSpareServers: maximum number of server processes which are kept spare
# MaxClients: maximum number of server processes allowed to start
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule mpm_prefork_module>
StartServers          5
MinSpareServers       5
MaxSpareServers      10
MaxClients          100
ServerLimit         150
MaxRequestsPerChild   2000
</IfModule>

Settings the MaxRequestsPerChild variable to 2000 means that each Apache process will be “recycled” 2000 times before it is forced to spawn a new Apache process.  The default is 0, or unlimited, which can lead to memory leaks.

Also set the KeepAliveTimeout low (2-5), to keep processes available for new connections instead of waiting on existing connections.

Here are some good resources that I used:

http://www.devside.net/articles/apache-performance-tuning

http://httpd.apache.org/docs/2.0/misc/perf-tuning.html

http://www.howtoforge.com/configuring_apache_for_maximum_performance

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>