Optimizing Apache2 !

mangelot

Verified User
Joined
Jan 11, 2007
Messages
70
Location
Enschede, Netherlands
Hello,
Does anybody has some optimized /httpd-mpm.conf for apache2.
I'm using an

Xeon 3.06,
2 gb memory
Centos 5.x

Its seems the load is high on httpd processes.

top output:

top - 21:00:10 up 10 days, 4:04, 2 users, load average: 2.99, 2.48, 2.73
Tasks: 154 total, 9 running, 145 sleeping, 0 stopped, 0 zombie
Cpu(s): 20.3%us, 1.9%sy, 1.5%ni, 73.2%id, 2.7%wa, 0.0%hi, 0.2%si, 0.0%st
Mem: 2075592k total, 1931864k used, 143728k free, 308456k buffers
Swap: 4096440k total, 152k used, 4096288k free, 573980k cached

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
30336 apache 16 0 194m 179m 2396 S 57 8.9 0:01.40 httpd
29224 apache 15 0 204m 189m 2788 R 27 9.4 0:13.90 httpd
28781 apache 16 0 201m 186m 2704 S 25 9.2 0:31.98 httpd
29696 apache 16 0 195m 180m 2436 R 25 8.9 0:11.81 httpd
29226 apache 16 0 196m 181m 2836 S 23 9.0 0:11.75 httpd
30402 root 25 0 1732 636 432 R 18 0.0 0:01.90 du
29726 apache 20 0 196m 181m 2452 R 6 8.9 0:10.23 httpd
29231 apache 21 0 204m 189m 2520 R 2 9.3 0:15.44 httpd
etc... etc...


Default config I'm Using:

<IfModule prefork.c>
StartServers 5
MinSpareServers 10
MaxSpareServers 15
ServerLimit 450
MaxClients 450
MaxRequestsPerChild 0
</IfModule>

<IfModule worker.c>
StartServers 2
ServerLimit 450
MaxClients 450
MinSpareThreads 25
MaxSpareThreads 75
ThreadsPerChild 25
MaxRequestsPerChild 0
</IfModule>

<IfModule perchild.c>
NumServers 5
StartThreads 5
MinSpareThreads 5
MaxSpareThreads 10
MaxThreadsPerChild 20
MaxRequestsPerChild 0
</IfModule>
 
Last edited:
setting a limit on the MaxRequestsPerChild will have processess killed more often and will help with memory usage but increase cpu utilisation.
MaxClients is the max total processes that can run, setting this lower saves memory and will also decrease your load average, however if below demand on requests people browsing sites on your server will get errors.

Check if keepalive is enabled or not, if its enabled set the keepalive timeout to one second, also try disabling it which in certian conditions does wonders for load average but will make apache slower on pages with lots of images.
 
Back
Top