Tag: linux
Apache extreme memory usage
by Geert on Sep.13, 2014, under Linux, Personal
My Apache webserver suddenly started to use an insane amount of RAM, freezing the whole box.. There are a couple of things you can tune in order to avoid this from happening. Obviously, one or more scripts are causing this issue. You could either go search for them by running the next commands :
ps -eo pmem,pcpu,pid,user,rss,vsize,args | { head -1 ; sort -k 1 -r -n ; } | head -10
This will sort the top 10 processes which eat away all the RAM. Run the following command to free up memory while you’re troubleshooting :
echo 3 > /proc/sys/vm/drop_caches
Change the next settings in your httpd.conf (typically found in /etc/httpd/conf/) :
<IfModule prefork.c>
StartServers 2
MinSpareServers 2
MaxSpareServers 5
MaxClients 150
MaxRequestsPerChild 500
</IfModule>
LoadModule deflate_module modules/mod_deflate.so
<Location />
AddOutputFilterByType DEFLATE text/html text/plain text/css text/xml application/x-javascript
</Location>
KeepAlive On
KeepAliveTimeout 2
MaxKeepAliveRequests 80
<Directory />
Options FollowSymLinks
</Directory>
<Directory />
AllowOverride None
</Directory>
ExtendedStatus Off
Timeout 45
Also, it might be worth having a look at Easyapache and add mpm-prefork, or else Nginx or Litehttpd..