LAMP droplet high memory usage with no traffic on Ubuntu 16.04

January 17, 2018 157 views
Apache Ubuntu 16.04

My Droplet (512 MB Memory, LAMP, Ubuntu 16.04) uses 70%+ of it's memory since I created it, even when I'm not running the application.

When I stop running my app, I can see the memory usage drop by 10 to 15%, but it's still consistently high. I have a firewall setup so only my and a colleagues IP have access to the app.

In the Graphs section of the Droplet I can see the following processes consuming the most energy (high to low):
apache2: 48%
mysqld: 29%
fail2banserver: 2.8%

All the other processes after that don't contribute significantly (less than 2%).

I've read this post, and if I runfree -m I get:

 total        used        free      shared  buff/cache   available
Mem:            488         347          22          16         118          94
Swap:             0           0           0

So it looks like the RAM really isn't available. How can I figure out what's going on?

1 comment
  • Just created a new droplet with the same settings (just the awesome new droplet with 2x memory). Exactly the same issue, from the moment of creation it uses 30% of the 1GB memory (so equivalent to 60% on the previous older droplet with 512MB memory).


    1. LAMP one-click app on Ubuntu 16.04
    2. Switched to ntpd timesync
    3. Increased some settings in php.ini (post-max-size, upload-max-filesize, memory-limit (to half of what the droplet has) and max-execution-time)
    4. Added a self-signed SSL certificate
    5. Enable mod_rewrite, also needed to do this:
    6. Installed PHPMyAdmin
    7. Installed CURL
    8. Ran mysqlsecureinstallation

    That's it. No idea what's consuming so much memory...

1 Answer

If you are concerned about memory usage you can use top to see which specific processes are using exactly how much RAM. The output you provided here from free only lists the totals which isn't very useful for troubleshooting.

There's a tutorial on reading output from top here:

After you review your usage you can decide that if something is using a lot of RAM and not needed to disable it.

But if you are running a lamp configuration you will have Apache, php, MySQL running, and then you can see which one of them is taking up the most resources.

Also note that if the server isn't under any load and using 30% memory, it doesn't mean that your RAM usage will immediately spike if you start to receive traffic, as a lot of the processes are just sitting there idling and waiting to process a request.

by Justin Ellingwood
Monitoring a server's resources is an important task for every administrator. There are many command line tools made for this purpose. This guide will cover some of the more popular utilities for monitoring your VPS.
Have another answer? Share your knowledge.