After maybe ~20 minutes it seems like my apache server becomes unconnectable. By unconnectable, I mean if I curl
any page, it just results in nothing for 2-3 minutes and then nothing ever shows up. I'm forced to restart apache to make it usable. The actual box itself seems fine, since I'm always SSH'd in... so I think this is just an Apache thing.
After ~3-5 minutes of stopping/starting the apache server, memory usage twindles:
One second it's:
CPU MEM
21997 root 20 0 459m 208m 8504 R 45.8 20.8 10:14.56 apache2
The next:
21997 root 20 0 459m 208m 8504 S 8.8 20.8 10:37.37 apache2
So one second it's at 40% CPU, 20% mem
There are only 2-3 small websites that use PHP, so there's no way they could be consuming that amount of memory. I'm wondering why this happens?!
My config for Apache (prefork) is:
<IfModule mpm_prefork_module>
StartServers 5
MinSpareServers 5
MaxSpareServers 10
MaxClients 150
MaxRequestsPerChild 0
</IfModule>
Server version: Apache/2.2.22 (Debian)
On Debian Wheezy using libapache2-mod-php5
I know mod_php
is probably not the most efficient and there might be better alternatives like php-fpm
, and/or using nginx
but I want to actually get at the root of the problem instead of avoiding it.
Would appreciate any tips.
The configuration for apache2 I believe is stock. Using DigitalOcean VPS, the 1GB Memory / 30 GB SSD / 2TB Transfer tier.
EDIT #1: I just read some Linode optimization article and it mentions turning KeepAlive
off on low memory servers. I'm going to try this and see how it goes.
Have you checked your logs? access.log and error.log?