Error establishing database connection

Hey There,

I’m getting database connection issues intermittently that affect multiple installations. Not sure what’s up because everything was working fine up until recently and then I started getting random DB errors. They fool my uptime monitors because technically they’re still up but not sure what’s going on. The only thing installed on these servers are easyengine, dome9 firewall and new relic monitoring.

I don’t know what the problem could be and any help would be great. Thanks.

I had this a couple of days ago as well. Rebooting my server fixed the issue and I haven't had time to dig into why.

Yes, a reboot fixed it for me as well and would love to know what's up. Glad to know someone else has encountered the issue as well. I'm not sure how to repeat it and that's compounding the issue. It's happened on a few different installs, all with different plugin configurations.

There are many reasons for database errors. Most common being, part of site is not cached and gets sudden spike in traffic, which results in a lot of php/mysql work.

You can find uncached parts using this tutorial - https://rtcamp.com/tutorials/nginx/upstream-cache-status-in-access-log/

EasyEngine already has correct log format. Just check, "BYPASS Requests URLs" section to find out which top URL's are BYPASSed. Try adding them to cache, and see if it makes any improvement.

With future EasyEngine release, we will add above and other cache analysis related tutorials in EasyEngine itself. For now, it will require some manual efforts.

thanks, from what I gathered through research the issue is related to memory around mysql. Basically when there's no memory left, mysql stops working properly. The caching side of it is definitely related as php5-fpm is taking roughly 80% of system resources at the moment and that's high for number of WP installs on the server. Anyway, I'll try the caching thing (although still not sure what to do with the bypass/adding to cache part) so if you could clarify that would be helpful.

Thanks,

James.

For mysql part, if swapping is not enabled on your server, enable swap memory. That way mysql will slow down when memory is exhausted but it will avoid (or delay) crashing.

For BYPASS URLs, depending on your wordpress/nginx config, you are supposed to force caching on them, wherever possible. There is no one size fit all solution here and it depends on application.

Also, another problem could be php/mysql programming issue. Many WordPress plugins are not coded/tested for large sites. EasyEngine's next release will have ee debug command which might help you find out such bad parts.

Reference: https://rtcamp.com/easyengine/docs/commands/debug