I have been experiencing MySQL crashing recently and really need to figure out what I need to do to get this to stop.
I have a 2GB Digital Ocean server running the following:
- Ubuntu 14.04
- PHP v5.5.9
- Apache v20120211
- MySQL v5.5.43
- WordPress v4.2
I also have 2GB of swap.
The last time MySQL crashed this was in my error log
The important part seems (to me) to be this
InnoDB: Fatal error: cannot allocate memory for the buffer pool
I am getting about 2000 page views per day. I thought this should be easily enough memory to run the site.
Can anyone give me some ideas what I can do or what I definitely need to do to stop this happening?
Thanks
2000 page views per day is well within the range of what your server can handle. It’s possible you’re getting hit by bots and/or Apache isn’t configured well for your server size.
Apache2Buddy is a quick diagnostic tool to help with your Apache configurations.
$ curl -L http://apache2buddy.pl/ | perl
. It’ll print out a report with suggested configuration adjustments given your RAM available and application size. My guess is that you’ll need to update MaxRequestWorkers (located at/etc/apache2/mods-available/mpm_prefork.conf
) to something smaller.I’m also guessing that you have bots hitting your site, which is causing the huge volume of traffic that is crashing Apache. Check your access logs
$ cat /var/log/apache2/access.log
.I wrote an article on this situation if you want a deeper explanation, a method to stress test, or ideas on how to block some of the bot traffic: http://brunzino.github.io/blog/2016/05/21/solution-how-to-debug-intermittent-error-establishing-database-connection/