I am often running out of memory on my VPS ubuntu server. I wish there was a way to simply restart apache2 when it starts running out of memory, as that seems to solve the problem. Or am I just too lazy to fix the problem? I do have limited memory on the server…
Okay, more information:
I'm running apache2 prefork, here are my memory settings (i've been tweaking them…):
StartServers 3
MinSpareServers 1
MaxSpareServers 5
MaxClients 150
MaxRequestsPerChild 1000
The VPS has 1 GB of ram, running ubuntu 11.04 32-bit.
As for scripts, I have a wordpress network with 5 blogs, an install of AskBot (a python/django stackexchange clone), and an install of MediaWiki that isn't really used. There is also a homebrewed mp3 script that accesses the getid3 library to display information on lists of podcasts, and it seems to be throwing some php errors, not sure if that's the culprit…
Best Answer
Monit can do this.
You could use a config line such as:
(Modified from this config example on monit.com)
This could play into the ulimit option mentioned earlier as well.
Restarting the service is a bandaid. You should instead try to find out why it's leaking memory.