SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Addict
    Join Date
    Jun 2005
    Posts
    257
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    MySQL Sleeping Connections

    According to my host and alot of review myself, I have a problem with sleeping mysql connections. On my online game when I have lets say around 30 online I have over 200 mysql sleeping connections.

    I have no idea how these connections are staying open. I always thought php automatically closed a mysql connection once the page was finished loading.

    What are sleeping connections?
    What causes mysql connections to stay in the sleep state and what can be done php wise to ensure they never make it to that point?

    mysqladmin processlist|grep Sleep|wc -l
    189

    Returns 189 sleeping connections right now.

    Thank you for any help or advice that you can give.

  2. #2
    Non-Member
    Join Date
    Dec 2006
    Posts
    269
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Xiosen View Post
    What are sleeping connections?
    What causes mysql connections to stay in the sleep state and what can be done php wise to ensure they never make it to that point?
    Did you check whether you are using persistent connections?

    mysql.allow_persistent=

    Rich

  3. #3
    SitePoint Addict
    Join Date
    Jun 2005
    Posts
    257
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    My host says:

    mysql.allow_persistent = On

  4. #4
    Non-Member
    Join Date
    Dec 2006
    Posts
    269
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Xiosen View Post
    My host says:

    mysql.allow_persistent = On
    Hi,

    You may want to consider turning them off:

    http://www.mysql.com/news-and-events...000000086.html

    Rich

  5. #5
    SitePoint Wizard cranial-bore's Avatar
    Join Date
    Jan 2002
    Location
    Australia
    Posts
    2,634
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What connection function does your PHP code use ? (mysql_connect, mysqli_connect, mysql_pconnect etc.)

    I've never heard of sleeping connections, but as long as you're NOT using permanent connections they should automatically be closed as each script finishes executing (as you said)

  6. #6
    SitePoint Addict
    Join Date
    Jun 2005
    Posts
    257
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Im using mysql_connect. I will check that link out richrf. Thank you.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •