Articles Comments

{ Berbagi, Menulis, Dan Mengajar } Ilmu… » Cms Drupal » How to resolve the “Too many connections” error?

How to resolve the “Too many connections” error?

The Drupal site for PHP-development students at the VDAB competence center at Dendermonde http://www.ict.teno.be/dendermonde has been down the second time now with the error: The mysqli error was: Too many connections.

What causes it? How to solve it?

I have been googling around for possible answers, and of course have found several differing points of view. Sometimes views even contradict.

My starting point was this article: http://drupal.org/node/51263#comment-180220 on Tuning MySQL Drupal.
Some insights given by the discussion on http://modxcms.com/forums/index.php?action=printpage;topic=27824.0.

  1. First of all. The point about a conflict between the length of the webserver thread and the length of a mysql persistent connection. I can be short on that one because I found this comment in my Drupal database.mysqli.inc: Note that mysqli does not support persistent connections. So even if I have the php variable mysql.allow-persistent set to on, it wouldn’t matter would it, using mysqli? So the IIS process, thread, whatever being shorter than a mysql connection, resulting in an orphan connection that can no longer be (re-)used can apparently not cause my particulari mysqli error.
  2. Obvious thing is to go and check the max_connections variable in the mysql configuration file. Standard is 100. Increase it to 250, for instance.
  3. You can also limit the allowed length of a connection. Change the default value of the mysql.connect_timeout in your php configuration file from 60 to 20 seconds. But I wonder what wille happen when this conflicts with a resource limit setting as max_execution_time. I guarantee you that reducing this max_execution_time will result in WSOD (white screen of death) upon heavy duty Drupal admin request or installing a new Drupal site.
    But, then again, this is another mysql option. Not mysqli?!
    In mysqli you can set timeout with mysqli_options($link, MYSQLI_OPT_CONNECT_TIMEOUT, 5) I don’t find Drupal using this.

Filed under: Cms Drupal

Leave a Reply

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>