Mysql Max_user_connections Errors at Bluehost

Bluehost’s current limitation for concurrent MySQL connections is 15 per user. When you get an error stating that you have reached the max_user_connections, it 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 connections than necessary. 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. There are some basic installation directions relevant to our environment here. 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 .

In addition to this, I recommend doing a MySQL repair and optimize on your databases, and consult your web developer for further assistance.

Leave a Reply