optimize apache

From WebHostingNeeds.com
Jump to: navigation, search

Check Apache Mode

[[email protected] ~]# httpd -l
Compiled in modules:
[[email protected] ~]

prefork.c => Apache running as prefork.

Check Memory Usage By Apache

ps -ylC httpd | awk '{x += $8;y += 1} END {print "Apache Memory Usage (MB): "x/1024; print "Average Proccess Size (MB): "x/((y-1)*1024)}'

Number Of Apache Process

ps -aux httpd | wc -l

Optimize Prefork

# 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
# ServerLimit: maximum value for MaxClients for the lifetime of the server
# MaxClients: maximum number of server processes allowed to start
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule prefork.c>
StartServers       8
MinSpareServers    5
MaxSpareServers   20
ServerLimit      255
MaxClients       255
MaxRequestsPerChild  4000

ServerLimit = MaxClients, that you need to set.

If you have 8 GB RAM on server, lets say we give Apache 4 GB RAM, then

MaxClients = (4 * 1024) / Average Apache Proccess Size.