Question

Help with Crashing Droplet

Hey all,

I spun up a new Ubuntu 20.04 1GB RAM droplet using Digital Ocean 1-click WordPress App a few weeks back and began developing the site. I’ve kept my WordPress plugins, themes, etc. pretty light (Wordfence is probably the heaviest one in use) and I haven’t uploaded much media just yet. I noticed the other day that I couldn’t access my site in the browser and after much loading, a message was just displayed that read “Error establishing a connection to the database” (I’m now behind cloudflare and just receive a timeout error when this occurs). During this time I tried to login to my droplet via SSH which was also very sluggish. Today I experienced a the same issue so I used grep -Ei 'oom|out of memory' /var/log/syslog to search for anything in the logs that might cause this issue and the following was displayed:

Jan 25 15:18:40 droplet kernel: [599977.961643] ib_pg_flush_co invoked oom-killer: gfp_mask=0x100cca(GFP_HIGHUSER_MOVABLE), order=0, oom_score_adj=0
Jan 25 15:18:40 droplet kernel: [599977.961722]  oom_kill_process.cold+0xb/0x10
Jan 25 15:18:40 droplet kernel: [599977.961936] [  pid  ]   uid  tgid total_vm      rss pgtables_bytes swapents oom_score_adj name
Jan 25 15:18:40 droplet kernel: [599977.962031] oom-kill:constraint=CONSTRAINT_NONE,nodemask=(null),cpuset=/,mems_allowed=0,global_oom,task_memcg=/system.slice/mysql.service,task=mysqld,pid=31337,uid=112
Jan 25 15:18:40 droplet kernel: [599977.962130] Out of memory: Killed process 31337 (mysqld) total-vm:1342776kB, anon-rss:439804kB, file-rss:0kB, shmem-rss:0kB, UID:112 pgtables:1264kB oom_score_adj:0
Jan 25 15:18:40 droplet kernel: [599978.039990] oom_reaper: reaped process 31337 (mysqld), now anon-rss:0kB, file-rss:0kB, shmem-rss:0kB
Jan 25 15:26:50 droplet kernel: [600468.028506] systemd invoked oom-killer: gfp_mask=0x100cca(GFP_HIGHUSER_MOVABLE), order=0, oom_score_adj=0
Jan 25 15:26:50 droplet kernel: [600468.028534]  oom_kill_process.cold+0xb/0x10
Jan 25 15:26:50 droplet kernel: [600468.028658] [  pid  ]   uid  tgid total_vm      rss pgtables_bytes swapents oom_score_adj name
Jan 25 15:26:50 droplet kernel: [600468.028754] oom-kill:constraint=CONSTRAINT_NONE,nodemask=(null),cpuset=/,mems_allowed=0,global_oom,task_memcg=/system.slice/mysql.service,task=mysqld,pid=67924,uid=112
Jan 25 15:26:50 droplet kernel: [600468.028885] Out of memory: Killed process 67924 (mysqld) total-vm:1310584kB, anon-rss:385228kB, file-rss:0kB, shmem-rss:0kB, UID:112 pgtables:1132kB oom_score_adj:0
Jan 25 15:26:50 droplet kernel: [600468.092875] oom_reaper: reaped process 67924 (mysqld), now anon-rss:0kB, file-rss:0kB, shmem-rss:0kB

MySQLs memory usage seems to be higher than normal and causing the droplet to run out of memory. Having such a small website with little to no real traffic I don’t think its WordPress or the droplets memory size, but am unsure if this is some type of attack or some configuration that was missed. Any insights on how to resolve or troubleshoot would be much appreciated!


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 @jplafata ,

Since you are running a Droplet with 1GB RAM, it is likely that the hardware resources are causing the out of memory errors. We recommend you to upgrade to a higher Droplet plan. However, you can always check with optimizing the MySQL instance, and then resize the Droplet as a last resort.

Potential solutions to out of memory problem are:

  1. Optimize your MySQL configuration. A great tool for this is MySQLtuner: https://github.com/major/MySQLTuner-perl

Note that the longer your server has been running before using this, the more accurate its suggestions will be. These settings are adjusted in /etc/my.cnf. You can get an example of the memory usage from your current or proposed settings with this calculator: http://www.mysqlcalculator.com

Based on your local memory status (free -m), you can adjust innodb_buffer_pool_size and key_buffer_size values in my.cnf file, so that MySQL doesn’t allocate more memory than available. You can also optimize MySQL service variables like max_connections, query_cache_limit, etc. Here’s an article that sheds more light on optimizing MySQL configuration parameters for servers running out of memory: https://www.percona.com/blog/2016/05/03/best-practices-for-configuring-optimal-mysql-memory-usage/

  1. Reduce your web application’s reliance on MySQL for page loads. This can usually be done by adding static caching to your application. For example, Joomla has caching as a built-in feature that can be enabled. Another example, WordPress can use plugins (like WP Super Cache) to add in this kind of functionality.

  2. Check what applications and processes are using RAM (e.g. by using ‘top’ command). A common culprit is Apache. If your server is short on memory, you can benefit by limiting requests during high load, rather than serving them and having MySQL or other processes killed when memory runs out. MaxClients/MaxRequestWorkers directives can be used to manage these limits in Apache.

  3. Resize up to a larger droplet. With any server utilizing a MySQL database, the size and type of data stored can significantly affect memory requirements. An upgraded server with more resources will likewise cost more money, so you should only go through with resizing if you’ve already tried other routes, and it truly ends up being your best option.

Hope this helps!

Cheers, Lalitha