Question

Apache Abnormal Memory Consumption, Causes?

Hello, i have a big big problem with Droplet

2 GB Memory / 40 GB Disk / NYC3 - Ubuntu 14.04.4 x64

After over 1 year use, seems now my drolet be affect by an unknow issues, an high ram consuption that stop all my websites.

Before move all my site on new droplet and destroy old, i want try fix it, so i am here to ask for help to community.

Information

  • Memory limit reach 100% and stay fix until droplet reboot and apache restart
  • After reboot and restart, websites working for 5 or 10 minutes, then memory consuption reach 100% and stay and i must restart apache and reboot droplet
  • Error occour also when no traffic is on the site
  • Error is no permanent and hit my droplet not more than 2 times in a days
  • Issues resolved after 6-10 times reboot and restart (droplet and apache), just for 2 days max or some hours.
  • All sites on the Droplet are Wordpress based.
  • Before never issues hit my droplet

Memory Consuption details

free -m
        total       used       free     shared    buffers     cached
Mem:          2001       1931         70        137          0        151
-/+ buffers/cache:       1778        222
Swap:         4095        188       3907

Here and image of GRAPHS: http://pasteboard.co/zg2icRnQ.jpg

Droplet workign good for some months with lots of websites on it, from issues incoming i removed 2 websites from server without any googd news.

Any help or suggestion will be appreciated Thank you All!

Subscribe
Share

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

@Stew @hansen

From looking at error.log output, the client denied by server configuration error is probably due to VirtualHost blocks not having a <Directory ...> block setup to allow the request through.

Apache differs from NGINX in that you have to allow access to directories instead of restrict access.

If you intentionally restricting access to that file, since it seems to be repetitive, then you may have a correct setup and the errors are just logging that access was denied. I’d have to see the VirtualHost blocks to really make that call, as well as your .htaccess file(s) – for each site.

As for the RAM usage, restarting the server will normally always brings things back online as you’re flushing everything when you do that. Everything starts from square one all over, resource usage begins to creep up, and then you’re back in the same situation.

The issue here, beyond the above errors, seems to be a matter of WordPress + WooCommerce, plus from what I can gather from the log, around 9 websites.

If each of those 9 sites are WordPress + WooCommerce:

1). 2GB of RAM most likely isn’t enough. WooCommerce is a heavy plugin and normally, in my past dealings with it, needs at least 1GB per instance (WordPress + WooCommerce).

2). Beyond RAM, you need to look in to optimizing your stack. This includes optimizing Apache, PHP, MySQL, etc. Default configurations are only starting points, they are not meant for production, so if you’ve not tweaked/tuned your stack, it’s not going to perform as well as it could/should. If you’re not able to do this yourself, I’d definitely recommend hiring a sysadmin (hey…I’m available :-)).

3). Beyond the first two, the hint that @hansen dropped would be dropping Apache in favor of NGINX as your web server, which I’d honestly recommend as well. It’s more performant and would likely reduce some of the RAM consumption alone, though you’d still need to look in to optimizing your stack for better performance and resource usage.

You can take the easy route and throw hardware at it (i.e upgrade to 4GB or 8GB), but you’ll soon be back with the same issue as throwing hardware at it only works for so long. Part of running a sever is optimization or hiring a sysadmin to do it for you. Beyond that, maintaining security, server updates, and perhaps most important, since it seems your current version is out of date, keeping WordPress and WooCommerce up to date as well.

@Stew

I expected to see more specific errors, but it looks okay in general. The reason I wanted to see the list of log files, was because sometimes Apache behaves in a strange way, if the log files grow to a very big size.

One thing I’m noticing, some of the sites are running WooCommerce, which is a very heavy WordPress plugin, so if you are running multiple WordPress sites and some of them using WooCommerce, then you might actually run out of RAM.

But it’s still weird that it didn’t make any difference, when you removed a couple of sites. Let’s see we can get some expert assistance.

@jtittle Have you seen this before? Apache using all memory with multiple WordPress+WooCommerce. You know what my off-the-bat recommendation would be.

Hi @Stew

There can be many reasons why, but I would think this might have something to do with PHP running as a module in Apache. Let’s see if the error logs tells us anything.

Can you run this command and post the list?

ls -lh /var/log/apache/

And then run this and post the output:

tail -50 /var/log/apache/error.log