After several nagios messages like "CRITICAL - load average: 135.12, 92.20, 44.09" and oom-killer, I checked the configuration again and again, with different settings, but no success.
The only work-around which seems to help on the ubuntu box, is this cleaner cronjob:
[ -x /usr/lib/php5/maxlifetime ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -depth -mindepth 1 -maxdepth 1 -type f -cmin +$(/usr/lib/php5/maxlifetime) ! -execdir fuser -s {} 2>/dev/null \; -delete
Reading the oom-killer info, tells me about apache2 to be the bad (parent) process. There is only few traffic on this vserver and hardly any peaks.
lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 1
free -m
Mem: 2003 835 1168 0 18 381
-/+ buffers/cache: 435 1568
Swap: 1019 129 890
apache2.conf mpm
<IfModule mpm_prefork_module>
StartServers 2
MinSpareServers 2
MaxSpareServers 10
MaxClients 150
MaxRequestsPerChild 10000
</IfModule>
<IfModule mpm_worker_module>
StartServers 2
MinSpareThreads 25
MaxSpareThreads 75
KeepAliveTimeout 15
ThreadLimit 64
ThreadsPerChild 25
MaxClients 100
MaxRequestsPerChild 10000
</IfModule>
<IfModule mpm_event_module>
StartServers 2
MinSpareThreads 25
MaxSpareThreads 75
ThreadLimit 64
ThreadsPerChild 25
MaxClients 100
MaxRequestsPerChild 10000
</IfModule>
Isn't there something like a mysql_tuner.sh for apache or a useful example for a similar vps?
THX
You are over allocating on memory - OOM means "Out of memory" - the high load averages will be a result of the machine swapping.
You don't need a tuning script to know what appropriate settings to use. Launch Apache, then look at the RAM usage of a single thread. Typically, for a PHP app, expect around 30MB. Then, you can start to figure out how many threads you can actually run.
You'll probably find you are over allocating memory at an app level (PHP max memory or MySQL) rather than the number of Apache threads itself; it is just that, that is the app tipping the usage over the edge.
For the time being, be very conservative, then work your way up. So lower the settings to something like this:
Then lower all your MySQL memory settings, or at the very least, the number of connections (to around ~15); and lower all your PHP max. memory settings.
Memory Usage Script
Here's a little script I wrote for memory usage, but bear in mind, it isn't going to properly factor in shared libs etc.
Just create a new file,
Eg.
/root/memory_usage.sh
Then run with the application name,
Eg.
/root/memory_usage.sh apache2
or/root/memory_usage.sh mysqld