Questions about MySQL: Too Many Connections

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cathode
    Member
    • Oct 2004
    • 88

    Questions about MySQL: Too Many Connections

    • How many connections can MySQL have?
    • Is the number of allowed connections based on per-account, or per-server?
    • Is there any way to monitor MySQL connections?
  • AndrewT
    Administrator
    • Mar 2004
    • 3653

    #2
    All of our servers have a limit of 10 concurrent connections for any given MySQL user. For all practical purposes on a busy site (as far as shared hosting is concerned), you wouldn't use more than 2-3 ever at the same time and even then it would only last a few ms. This limit is just in place to prevent abuse, it doesn't mean you are free to run 10 concurrent connections all the time. Unfortunately this is not something easily tracked by an end user but if you are getting this message on our servers then it almost always means you have a script that is running a poorly written SQL query.

    Comment

    • cathode
      Member
      • Oct 2004
      • 88

      #3
      Originally posted by AndrewT
      All of our servers have a limit of 10 concurrent connections for any given MySQL user. For all practical purposes on a busy site (as far as shared hosting is concerned), you wouldn't use more than 2-3 ever at the same time and even then it would only last a few ms. This limit is just in place to prevent abuse, it doesn't mean you are free to run 10 concurrent connections all the time. Unfortunately this is not something easily tracked by an end user but if you are getting this message on our servers then it almost always means you have a script that is running a poorly written SQL query.
      10 seems really low. I get this error often with forums (various forum software.) And I'm talking about small forums too, nothing huge.

      Comment

      • AndrewT
        Administrator
        • Mar 2004
        • 3653

        #4
        It really isn't. You should not be using anywhere near that amount. This isn't the same as having 10 concurrent users on a forum or blog. Connections to MySQL open, execute, and close near instantaneously in most cases. If you run into this error then you have a query that is taking too long to execute or a query that is locking tables and causing queries to queue up waiting on the lock thereby permitting this limit to be reached.

        Comment

        • ZYV
          Senior Member
          • Sep 2005
          • 315

          #5
          Also note, that many PHP scripts use 'persistent' connections by default. I do not know the details on how PHP is set up with Dathorn, but I assume that a new processes is forked for each request, at least it used to be the case. In this scenario, persistent connections are not only useless but plainly harmful and you absolutely should turn them off.

          The limit of 10 concurrent connections is not so easy to reach if the application is programmed correctly. I suggest you having a look at scripts configuration first.

          Comment

          Working...