Anyone know how to cut off too many mySQL connections?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • JenC
    Confirmed User
    • Jun 2002
    • 515

    #1

    Anyone know how to cut off too many mySQL connections?

    My server is getting bombarded with too many mySQL connections, how can I cut some of them off.
  • n0de
    Confirmed User
    • Jan 2003
    • 250

    #2
    modify /etc/my.cnf and reduce the value of 'max_connections'
    ICQ: 113090760
    Im too sexy for my sig.

    Comment

    • JenC
      Confirmed User
      • Jun 2002
      • 515

      #3
      I restarted apache and that seemed to do the trick. Thanks for your response.

      Comment

      • Clarion
        Confirmed User
        • Jan 2005
        • 148

        #4
        That may do it only temporary. The main cause of your problem most likely is the script youre using is bottlenecking mysql, and eventually may come back. The best thing to do if this happens again would be to reevaluate your script and work out any effeciencies. The other option for a temporary fix is to up your max connections count, however this won't improve the situation. Let me know if we can help you out. Drop me a line on ICQ: 342-801-972
        Structure Northwest :: the cure for the common code ::
        AIM: Asatruel | Yahoo!: Asatruel | ICQ: 111-638-053

        Comment

        • V_RocKs
          Damn Right I Kiss Ass!
          • Nov 2003
          • 32468

          #5
          mysql_close($db); as the last line in your sql using php files. (assuming $db is the value assigned to the connection when you opened it).

          Comment

          • rickholio
            Confirmed User
            • Jan 2004
            • 1914

            #6
            Originally posted by V_RocKs
            mysql_close($db); as the last line in your sql using php files. (assuming $db is the value assigned to the connection when you opened it).
            PHP auto-closes SQL connections after page execution unless persistent connections are requested. It wouldn't fix the problem: if PHP is fine, nothing's been accomplished... if PHP or apache is acting funny, then it just obscures the problem without fixing it. Indeed, if you mysql_close() a shared connection, you might blow other things up. You're better off letting the resource reclaimation happen automatically in this case.

            This all assumes that PHP is being used. For all we know it's JDBC, DBD::Mysql or an ODBC connection from a windows box running apache...
            ~

            Comment

            Working...