Received Sat, 29 Nov 2008 18:16:46 PHT
Apache performance optimization prefork. Less servers sometimes gives more performance - Simple Apache MPM prefork configuration tuning howto
Optimizing the number of httpd2-prefork instances on your server
My system: openSUSE 11.0 x86_64, Apache2.2 -the server tuning also works on older openSUSE version!
In my ongoing current work to configure the new Cyberspace Ashram server I have waiting time until a new ISP is found. Waiting is a fatal waste of available resources, hence I study and learn performance tuning to maximize security and optimize apache performance.
These weeks are lucky weeks, traffic is the highest of the year, every year during the many weeks before Christmas. Hence server performance tuning is ideally done during peak traffic times / peak traffic hours.
About a week ago the load was in the range of 2 and CPU usage 50% or more during max peak traffic hours. Hence I studied / searched for opinions, data and facts online and made some tests myself about server tuning and server performance optimization.
Now after several days of successful testing the new server tuning during even higher traffic, the newest top data are shown below. As you know, such top data change every few seconds. I chose average data as they are normal now. Rarely a very few % higher in CPU but normally rarely more than 20-30% and load even peak single seconds never near or even above 1. Typically a very rare and only few seconds lasting load peak sometimes reaches around 0,7 - but average load during max peak seconds during peak traffic hours is as shown below:
Data below from maximum peak traffic hours:
top - 06:52:43 up 22 days, 19:52, 4 users, load average: 0.52, 0.35, 0.29
Tasks: 105 total, 3 running, 102 sleeping, 0 stopped, 0 zombie
Cpu(s): 28.9% us, 3.3% sy, 0.0% ni, 64.1% id, 3.3% wa, 0.3% hi, 0.0% si
Mem: 2059996k total, 1482388k used, 577608k free, 46880k buffers
Swap: 2096440k total, 54744k used, 2041696k free, 638960k cached
My server-tuning.conf before optimization
My original prefork server configuration /etc/apache2/server-tuning.conf before server tuning was:
<IfModule prefork.c>
StartServers 20
MinSpareServers 10
MaxSpareServers 20
ServerLimit 150
MaxClients 150
MaxRequestsPerChild 10000
</IfModule>
My currently optimized server-tuning.conf
After my retuning above data to the current:
vi /etc/apache2/server-tuning.conf
<IfModule prefork.c>
StartServers 10
MinSpareServers 5
MaxSpareServers 10
ServerLimit 150
MaxClients 150
MaxRequestsPerChild 10000
</IfModule>
Test your configuration and restart your Apache server
rcapache2 extreme-configtest
If OK then
rcapache2 reload
or
rcapache2 restart
else - correct until configtest OK
After one week peak traffic testing of above server performance tuning, all works better than ever before. Depending on your exact traffic you may vary a little. But keep in mind that starting your entire Apache server with fewer StartServers and fewer MaxSpareServers may result in overall better performance.
There is another aspect and reason for precise optimization of your IfModule prefork.c. That is the need by mod_evasive for a correct IfModule prefork.c configuration. Shortly I may publish my mod_evasive configuration that mostly failed with my initial OLD IfModule prefork.c.
Additional Apache MPM prefork or Apache MPM Common Directives, more help and documentation is found on Apache.org - Apache MPM prefork and Apache MPM Common Directives
An additional server performance tuning step I did in combination with above Apache MPM prefork is the Server performance improvement with mod_cache.
Love and Bliss
hans






