By collegehoopsnet on
Starting about a week ago, once a day my site gets hit with the dreaded "Too Many Connections" error, caused by Drupal.. which eventually causes the entire site to slow to a hault followed by me calling the server host to reboot the server. Then once they do that the site runs 100% for 23 hours before it crashes due to the same error.
I know there are threads about that error on here, but everything I try doesnt seem to fix anything. My guess is that maybe there's a faulty script somewhere or who knows.
Any help on a step by step (treat me like an idiot)(ie, what logs to check, what settings to check, etc) way to figure this out would be appreciated!
Comments
There are a couple of things
There are a couple of things that could cause this. The obvious is traffic. During peak times you could be seeing more than the max number of users. In reality, it is probably something else.
What database are you running? MySQL? PostgreS?
I have some experience with Drupal using MySQL so I will talk from that point.
I have noticed in the past that have "persistent connections" turned on will cause a max_connection error, since for some reason php was not releasing connections.
try changing the php_pconnect to php_connect.
You may also notice this if you have your connections time out value set too low.
Change the wait_timeout from 24400 (or 28800, I forget which) to 60 - 180. You should also increase your thread_cache when you do this so you aren't constantly creating new connection threads.
Check to make sure that you web server can not send more connections to your database than you have max connections.
The default max_connections is 100. Apache should have its max workers tuned down from the default 256 to something more like 120 or even 100 depending on your site.
You could also be suffering from queries backing up because common queries are taking too long. Try turning on your query_cache. Using Drupal's page caching will also save you a bit on page load times, thus reducing the amount of backlog the DB will see.
Great stuff
Hello cguill,
This stuff is all good. We've been finding that the wait_timeout on our DB is 28800. What we've had problem with is changing the setting my.cnf, so when I've restarted MySQL (4.1-- Linux), I've had to go into the MySQL browser and set it to
set @@wait_timeout = 1800;(I went with that number because some our queries are running long-- another issue).
When you talk about "max workers" in Apache, I am not following. Is this an Apache 2.0 setting? We're using Apache 1.3.37
All the best,
Mike
This is the latest reply
This is the latest reply ever. over a year.. not sure why I never responded back then but all these tips were, and still are now, very helpful.