Out Of Memory (Is It Possible)

Posted November 11, 2015 16.4k views


I am running a wordpress installation on a $20 droplet (2gb | 2 core ), which i thought would be more than enough to run a wordpress site with 300 hits a day.

I keep getting the ‘Error establishing database connection’, and i have to keep restarting the server.

Is it possible to find out what is causing the memory errors, and how much memory i need?

I’ve ran a view commands and i can see that:

/var/log/mysql/error.log:151111 8:38:10 InnoDB: Fatal error: cannot allocate memory for the buffer pool 
/var/log/mysql/error.log:151111 8:38:11 InnoDB: Fatal error: cannot allocate memory for the buffer pool

Thanks in advance for your help.

1 comment

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.

Submit an Answer
4 answers

Hi, thank you.

What does free-m do?

@mosaic - The free -m command will output something such as:

                    total      used       free     shared    buffers     cached
Mem:                2000       1982         18          0         95       1666
-/+ buffers/cache:              220       1780
Swap:               0             0          0

What this means is that I have 2000MB of RAM, I’ve “used” 1982MB, of which 1666MB is cached and 95MB is buffer.

You can also use

free -mh

for an easier to read and pre-converted output which is converted to MB & GB instead of the default shown above, such as:

                    total       used       free     shared    buffers     cached
Mem:                 2.0G       1.9G        20M       632K        88M       1.6G
-/+ buffers/cache:              210M       1.7G
Swap:                  0B         0B         0B

What this does is simply tell you how much RAM you’re currently utilizing as of command execution.

That said, the free -m or free -mh command isn’t going to tell you where your problem is. You really need to look at RAM usage by process, specifically MySQL, Apache/NGINX, PHP etc.

To start, I’d advise downloading, installing and running MySQL Tuner (installation and usage details are on the main page of the site). This needs to be done as the root user from the command line interface (CLI). Once executed, it’ll provide you with a plethora of information that can be used to diagnose RAM usage by MySQL as well as overall performance.

If you would, run MySQL Tuner, copy & paste the results in a PasteBin and post the link to the PasteBin here. I’ll be more than happy to look over it for you.

It’ll also be helpful to see what the top output is. You can do this by running:


And then pressing shift m followed by c on your keyboard. That’ll sort the processes by RAM usage and expand the commands / processes. You can then select (copy) and paste that in to the PasteBin as well.

To expand on the “used” RAM above, simply because I’ve “used” 1.9GB out of the 2GB I’ve been allocated does not mean that I’ve used that much. The 1.6GB’s from the cache column is included in that 1.9GB’s, so my actual usage is only ~300MB. The other 1.3GB is cached and used by current processes until they are either stopped, killed or restarted.

This particular Droplet does not have a swap allocation, which is why swap reports all 0’s.

  • @jtittle thank you.

    When / If it times out again, i’ll get the report to you, thanks again… much appreciated.

    • @mosaic - No problem, though I wouldn’t wait if this has been a recurring issue. As long as MySQL has been running for at least 24 hours, the output from MySQL Tuner will be valid. Ultimately, finding out what the issue is now would be better than waiting until you install another plugin, a heavier theme, or simply see increased traffic.

      Like PHP-FPM, when you restart MySQL, the cache is wiped, thus you start from square one all over. Queries will be cached as they are called (if query caching is enabled – by default, on most configurations, it’s not), though it’s best to simply keep a running cache (where and when possible) with as few interrupts as possible.

      The process of testing various configurations will take a little time as well as, unless the new configuration immediately results in MySQL crashing, we’ll need to wait 24 hours on each update.

      • I have noticed that the company’s staff (50+ employees) emails had a piece of code in the footer that was referencing icons that were on their old server, which were not actually on the new server which resulted in 1000’s of calls a minute.

        I copied these files to the server and the memory dropped considerably. They are also changing their email footer so that it doesn’t not make a call to the website every time an email is opened.

I had the same issue, identical droplet size. It was an XML-RPC attack (Wordpress related).

Check this article for help:
How To Protect WordPress from XML-RPC Attacks on Ubuntu 14.04

by Jon Schwenn
WordPress is a popular and powerful CMS (content management system) platform. Its popularity can bring unwanted attention in the form of malicious traffic specially targeted at a WordPress site. There are many instances where a server that has not been protected or optimized could experience issues or errors after receiving a small amount of malicious traffic. This guide will show you how to protect WordPress from XML-RPC attacks on an Ubuntu 14.04 system.

Hello, all

You will most definitely need to upgrade your droplet as you’re running out of memory and your application/website needs more resources in order to continue to operate.

What you can also do is to use the MySQLTuner script.

The MySQLTuner is a script written in Perl and allows you to quickly test your MySQL configuration and it gives you suggestions for adjustments to increase performance and stability.

According to the official GitHub page, it supports 300 indicators for MySQL/MariaDB/Percona Server in this last version.

To run the script you could do the following:

  • SSH to your Droplet
  • Download the script:
wget -O
  • Then execute it:

The script would run multiple checks against your MySQL instance, all checks done by MySQLTuner are documented here.

Also as stated in the official documentation, it is still extremely important for you to fully understand each change you make to a MySQL database server. If you don’t understand portions of the script’s output, or if you don’t understand the recommendations, you should consult a knowledgeable DBA or system administrator that you trust.

As a good practice make sure to always test your changes on staging environments before implementing them on your production database.

On the same note, if you want to have a worry-free MySQL hosting and focus on your application, I would recommend trying out the DigitalOcean Managed Databases:

This was mini tutorial was posted from bobbyiliev in this question in our community:

Hope that this helps!