Database Connection Error

If your hosting has put a limit on simultaneous MySQL connections per account, you will get Database Connection error on your website when your database connections exceed limit on the server. It depends upon your database queries connections hitting to the server. Most sites will work perfectly with a 25 concurrent processes limit. Processes open and close so quickly that they hardly ever overlap.

If your website is exceeding the database connection limit, you need to optimize your database (for faster queries). Also, you should check your code to see if you are closing the connections correctly. the connections can also be there because you use pooling, so the system can reuse exist connections.

I am pasting some techniques to optimize your database:

1)  long-running process on MySQL

Please do a query level optimization to avoid long running queries.

i) http://dev.mysql.com/doc/refman/5.0/en/kill.html
ii) http://rugmonster.org/2009/02/kill-mysql-procs/

2) large or complex query

i) http://www.mysqlperformanceblog.com/2007/01/17/performance-impact-of-complex-queries/
ii) http://20bits.com/article/10-tips-for-optimizing-mysql-queries-that-dont-suck

3) Adjust wp--cron for WordPress

We also recommend making your wp-cron.php script run as a normal scheduled task instead of on every page visit. Here are instructions on how to make this change "http://wp.tutsplus.com/articles/insights-into-wp-cron-an-introduction-to-scheduling-tasks-in-wordpress/".

4) Optimize database using phpMyAdmin

http://support.hostgator.com/articles/specialized-help/technical/how-to-optimize-a-mysql-database-using-phpmyadmin

5) Do proper indexing on tables

i) http://stackoverflow.com/questions/1108/how-does-database-indexing-work
ii) http://www.developer.com/print.php/3667831

Thank you.

Comments

Popular posts from this blog

SVN: File remains in conflict

HowTo: Enable extended logging for exim

12 tweakings for WHM/cPanel to speed up WordPress