Question

Out Of Memory (Is It Possible)

Hi,

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.

Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

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

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

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 http://mysqltuner.pl/ -O mysqltuner.pl
  • Then execute it:
perl mysqltuner.pl

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:

https://www.digitalocean.com/products/managed-databases-mysql/

This was mini tutorial was posted from bobbyiliev in this question in our community: https://www.digitalocean.com/community/questions/how-to-tweak-mysql-mariadb-configuration-for-increased-performance-and-stability

Hope that this helps! Regards, Alex

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

@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:

top

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.