We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28779
    • 25 Posts
    I had my first experience with a ’too many connections’ error message on a client site today.

    I’ve looked through the forums, and there doesn’t seem to be any consensus on whether or not there is actually an issue with MODx on this matter. I’ve seen some vague solutions mentioned in the forums. One suggestions was to turn off logging and stats. OK, but these are not even turned on on my site.

    Has any tried typing "modx too many connections" into Google. The interesting result is that instead of getting support threads about the ’too many connections’ problem you will instead see a long list of live sites which have suffered the ’too many connections’ problem. And even if the site is available when you click through, you at least know that it was affected at the time when Google crawled it.

    If you go directly to the forums, and search for ’too many connections’ there are a couple of pages of responses, but nothing concrete for me to go on. If Drupal and OSCommerce can manage without causing this kind of error, why can’t MODx. I find this frustrating because I feel like there is not much I can do to prevent this happening again, and therefore inevitably there will be a call coming in from an angry client.

    So it seems to me that the MODx community might be in denial about the problem.

    So my questions:

    * What precisely in MODx is causing the problems?
    * Is there something that can be done to patch MODx to prevent these errors in the future?
    * Are there any plans by the MODx dev team to review the MODx database API in the future?

    Thanks
    Subd
      • 25663 MODX Staff
      • 12,272 Posts
      Googling for MODx too many connections = ~1410 results

      Googling for oscommerce too many connections = ~3920 results

      Googling for Drupal too many connections = ~13,800 results

      I’d be willing to wager that you’re simply running your site on an overloaded shared server or an improperly configured MySQL server.

      Where is your client site hosted?
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
        • 22303 MODX Staff
        • 10,725 Posts
        Quote from: subd at Aug 04, 2008, 11:31 AM

        Has any tried typing "modx too many connections" into Google. The interesting result is that instead of getting support threads about the ’too many connections’ problem you will instead see a long list of live sites which have suffered the ’too many connections’ problem. And even if the site is available when you click through, you at least know that it was affected at the time when Google crawled it.
        This is generally caused by either MySQL configurations that limit the number of connections and/or too much traffic for the server configuration to handle. Each request to your site requires a connection, but it is closed as soon as the request is completed. This is PHP/MySQL configuration, and not anything to do with MODx specifically. BTW, if you search for "oscommerce too many connections" or "drupal too many connections" you get similar results.

        Quote from: subd at Aug 04, 2008, 11:31 AM

        If you go directly to the forums, and search for ’too many connections’ there are a couple of pages of responses, but nothing concrete for me to go on. If Drupal and OSCommerce can manage without causing this kind of error, why can’t MODx. I find this frustrating because I feel like there is not much I can do to prevent this happening again, and therefore inevitably there will be a call coming in from an angry client.

        So it seems to me that the MODx community might be in denial about the problem.

        So my questions:

        * What precisely in MODx is causing the problems?
        * Is there something that can be done to patch MODx to prevent these errors in the future?
        * Are there any plans by the MODx dev team to review the MODx database API in the future?
        Again, this is not something specific to MODx; the current manager does use a lot of connections because of the nature of the frame-based layout, but if you have a reasonable configuration setup on a server that is not oversold (i.e. overloaded with clients), you will never run into this error. I run a lot of MODx sites on various servers and rarely if ever get this error; if I do, it’s because traffic demands are too heavy on one of the sites on the server or a database upgrade wasn’t performed properly and the configuration needed to be tweaked.

        See http://dev.mysql.com/doc/refman/5.0/en/too-many-connections.html for details on how to configure the server properly if this is becoming a common problem for you. If you are on a shared server, you need to discuss with them how to properly configure the MySQL server.
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          It can also be caused by poor configuration of Apache and Mysql and persistant connections. If an Apache thread finishes, but the pconnect timeout is too long, the connection to the database will still be open and cannot be re-used until it times out. If this happens too many times, you’ve got all those orphaned database connections hanging around and that can very quickly bring the database to its knees.

          Just a cursory look at a couple of quick Google searches would have made it clear this is not a MODx problem.

            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 28779
            • 25 Posts
            Quote from: rthrash at Aug 04, 2008, 11:48 AM

            Googling for MODx too many connections = ~1410 results

            Googling for oscommerce too many connections = ~3920 results

            Googling for Drupal too many connections = ~13,800 results

            On this, oscommerce has been around for a lot longer than MODx, hence more results - and this misses the point anyway. On the first page of Google results for ’modx too many connections’, 5 of the first 10 results were broken sites (at least in the Google cache), rather than support/forum pages about the problem. When you do the same for OSCommerce and Drupal most of the results are support pages rather than broken sites. This was my point, and what made me question whether this might be more than coincidence.
              • 22303 MODX Staff
              • 10,725 Posts
              Quote from: subd at Aug 04, 2008, 12:34 PM

              On this, oscommerce has been around for a lot longer than MODx, hence more results - and this misses the point anyway. On the first page of Google results for ’modx too many connections’, 5 of the first 10 results were broken sites (at least in the Google cache), rather than support/forum pages about the problem. When you do the same for OSCommerce and Drupal most of the results are support pages rather than broken sites. This was my point, and what made me question whether this might be more than coincidence.
              So the question is, is this a shared server, possibly overloaded with clients? What is the current setting for max connections in your MySQL configuration? You can theorize all day about your google results, but in the end, what matters is your MySQL configuration and the amount of traffic your server is handling.
                • 15083
                • 697 Posts
                Get a dedicated server (if you can afford one).

                My experience with shared hosting (in Ireland) is that hosts keep adding sites until their servers begin to fall over wink
                Your also contending with every wouldbe developer writting the worst code known to man, endless while loops etc etc...

                At least if you crash a dedicated server you have no one else to blame but yourself smiley