Question

LAMP droplet high memory usage with no traffic on 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 run free -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?

Subscribe
Share

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).

Config:

  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: https://forum.bludit.org/viewtopic.php?t=855
  6. Installed PHPMyAdmin
  7. Installed CURL
  8. Ran mysql_secure_installation

That’s it. No idea what’s consuming so much memory…


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.

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: https://www.digitalocean.com/community/tutorials/how-to-use-top-netstat-du-other-tools-to-monitor-server-resources#top

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.