Skip to content

Prevent MySQL crashing

Gaurav Ashtikar edited this page Aug 5, 2014 · 4 revisions

EasyEngine (ee)

Prevent MySQL crashing issue

On our support forum and GitHub issue tracker, we are seeing some are facing MySQL crashing issue. This issue is commonly observed on Digital Ocean 512 plan. We are still working on preventing MySQL crash, below are some common points and measures observed.

1. Low Swap Memory

For all VPS we recommend at least 1GB swap.

There is very nice article for crating swap. Link: https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04

2. Adjusting PHP5-FPM max children

By default EasyEngine sets this values to 100, thanks to Kym for pointing, on low RAM VPS, for high traffic PHP5-FPM takes nearly all RAM, leaving no RAM to MySQL

Changing PHP5-FPM max connectios: Open www.conf file:

vim /etc/php5/fpm/www.conf

For less that 1GB RAM, set

pm.max_children = 10

For less that 2GB RAM, set

pm.max_children = 20

For less that 4GB RAM, set

pm.max_children = 50

After that you need to restart PHP5-FPM

php5-fpm -t && service php5-fpm restart

You can also follow this tutorial to tune PHP5-FPM

3. Tunning MySQL

Tunning MySQL is always good practice. You can use following command to get MySQL tunning suggestions.

  • MySQL Tunner
mysqltuner
  • Tuning Primer
tuning-primer.sh

Adjust the MySQL values as per suggestions in my.cnf file

vim /etc/mysql/my.cnf

and restart MySQL

service mysql restart

If you still facing MySQL crashing issue, we are always ready to help you, for this you can use this thread: #244

Clone this wiki locally