0

My site (which as running fine until yesterday - CPU was at 2%, memory at 50%) keeps maxing out the resources - CPU and Memory at 100% and "load" and Disc IO very high.

the site is a php (silverstripe) site running on Ubuntu linux with apache and mysql.

Looking at the memory:

ps aux  | awk '{print $6/1024 " MB\t\t" $11}'  | sort -n

I get 150 entries for apache2 all with 40-90Mb. plus 475Mb for mysql and 331Mb for Java.

So it seems apache is starting too many processes and eating all the resources. Is that right?

If I restart apache, the site comes back up and works fine for an hour or so and then builds up lots of apache entries in ps and crashes.

how can i configure apache to not use up all the resources and avoid the website crashing? How can I find out what is causing the site resources to max out?

Update:

#/etc/apache2/mods-enabled# cat mpm_prefork.conf
<IfModule mpm_prefork_module>
    StartServers             5
    MinSpareServers       5
    MaxSpareServers      10
    MaxRequestWorkers     100
    MaxConnectionsPerChild   0
</IfModule>

Phpinfo

https://gist.github.com/asecondwill/bd9640cae780fa87a3af05be335aa3fb

Will
  • 131
  • 1
  • 1
  • 6

1 Answers1

1

This goes way beyond the scope of an answer here. But some pointers might be helpful. First, don't try to measure memory usage using ps - reality is so much more complicated. Better to use 'free'. Limit the number of connection with max_clients.

On a web server, avoiding swap is really critical. If you have it switched on, turn it off now. Also limit the memory overcommit to capacity + 15% (and be prepared to revisit this).

Use mysql_tuner.pl to check your mysql config. Ensure that the memory is capped at a sensible level.

Since your main issue appears to be capacity, do make sure you are running php-fpm, not mod_php, and consider switching out Apache for nginx.

symcbean
  • 23,767
  • 2
  • 38
  • 58