Performance Tuning Apache 2.x (mpm prefork)

Comments: No Comments
Upper page: Apache2

Found this on the internet for slice VSs. Though owned by rackspace now, still a helpful forum. This works great for a 256Mb slice. I have it on a 512Mb and there it rocks as well. I will likely tweak further for the 512Mb. Regardless the anecdotal evidence was spot on for both situations.

WHAT I DID

vi /etc/apache2/apache2.conf
# and make it so
[...]
    KeepAliveTimeout 5
[...]
    StartServers           3
    MinSpareServers        3
    MaxSpareServers        3
    ServerLimit           50
    MaxClients            50
    MaxRequestsPerChild 1000

Also, a nifty shell script to give you an idea of MaxClients. Now I did not use this number it recommended, but it is still a helpful tool


#!/bin/bash
echo "This is intended as a guideline only!"
if [ -e /etc/debian_version ]; then
    APACHE="apache2"
elif [ -e /etc/redhat-release ]; then
    APACHE="httpd"
fi
RSS=`ps -aylC $APACHE |grep "$APACHE" |awk '{print $8'} |sort -n |tail -n 1`
RSS=`expr $RSS / 1024`
echo "Stopping $APACHE to calculate free memory"
service $APACHE stop
MEM=`free -m |head -n 2 |tail -n 1 |awk '{free=($4); print free}'`
echo "Starting $APACHE again"
service $APACHE start
echo "MaxClients should be around" `expr $MEM / $RSS`

Resources

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.


Welcome , today is Sunday, May 19, 2024