Lately, my blog Success Stories (has a daily viewership of about 2500 people) has been showing "Error establishing a database connection" quite frequently. My wife had developed this theme from scratch without prior knowledge (she learnt web design in course of developing it)
Earlier, I thought it was because of the "ordinary host-serving plan" so I got it upgraded to the premium one. But the problem remains unsloved. I contacted BlueHost and asked them if there was something they could do about it, to which they sent the following suggestion. Can anybody go through it as well as my blog and explain the solution in the simplest possible words?
"I apologize for the trouble you're experiencing.Our current limitation for concurrent MySQL connections is 15 per user; The error you're receiving means your application is trying to establish more than 15 simultaneous MySQL connections with the same username at any given time, and the MySQL server is denying them.
To fix this, you'll need to prevent your program from making more than necessary connections; Unfortunately this can be a bit difficult to track since there's no simple way to see what script/page is establishing the connection, but I can offer these suggestions; * Slowly performing queries may keep a script and connection open longer than necessary. Check your ~/tmp/mysql_slow_queries/ logs for entries on what queries are taking too long to finish. * Disable any plugins or extensions you may have; Some of these are poorly coded and will keep open MySQL connections or needlessly re-open connections, with no regards to server limitations. * Verify the program is up to date. * Try using FastCGI and Persistent MySQL Connections together. FastCGI is a separate way of handling PHP, that allows it to start a script and keep a script running for up to 5 minutes at a time, ergo allowing multiple requests per process to be served. This is enabled from cPanel > Software/Services > PHP Config > PHP5(FastCGI). Persistent MySQL connections cause your MySQL connections to stay open for the same query, allowing each connection to perform multiple queries, versus opening, querying, returning data, closing, ad infinitum. In conjunction these two modifications can help alleviate issues with connection problems. To enable Persistent MySQL connections, please consult the FAQ or user documents for your installed program.* Verify your program is not being spammed by bots. Forums, comment sections and data fields that input to a database can be compromised or exploited to cause issues like the ones you're seeing. Check your ~/access-logs/ for logs about what is being accessed to check to see if there are any abusive patterns.* I recommend implementing a caching tool. Essentially caching is a tool or extension that takes requests from a certain interpreter (PHP, in your case) and stores a static copy of the whole or parts of a whole page; this allows Apache (web server) to serve subsequent requests, without having to redundantly query and obtain unchanged information, thereby reducing the number of MySQL connections it needs to return the same information. One we have seen great success with is xCache; this is non-supported, but does install properly in our environment--Myself and several other technicians here have done so, but please be aware it's as-is, and we will not be able to provide any installation help with it. In any case, it can be obtained from here: http://xcache.lighttpd.net/
There are some basic installation directions relevant to our environment here: http://matt2themax.com/xcache.html. If you want to do it per-script, investigate the use of a "Caching" style plugin. Scripts like Joomla have this built into the administrator section, and WordPress has a great plugin for this available here; http://wordpress.org/extend/plugins/wp-super-cache/
In addition to this, I recommend doing a MySQL repair and optimize on your databases, and consult your web developer for further assistance.
Our current limitation for concurrent MySQL connections is 15 per user; The error you're receiving means your application is trying to establish more than 15 simultaneous MySQL connections with the same username at any given time, and the MySQL server is denying them.
I will appreciate your help.