The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

BEWARE! mysql_pconnect could harm your server.

Discussion in 'General Discussion' started by kiat, Nov 17, 2004.

  1. kiat

    kiat Active Member

    Joined:
    Oct 11, 2001
    Messages:
    30
    Likes Received:
    0
    Trophy Points:
    6
    Hi,

    I would like to share this experience with everyone who might fall in to the same situation like me. Last month my server will be crashed every couple days randomly. Few days ago, I just found that it was from I have too many mysql connections. Below is an output from top command that I got before the server go down. I have 402 process running and 170 process were mysql. After this for a few mintues, the server will go down with last CPU load average that I saw about 62.

    16:41:56 up 5 days, 50 min, 0 users, load average: 30.52, 19.98, 9.79
    402 processes: 395 sleeping, 2 running, 5 zombie, 0 stopped
    CPU0 states: 0.1% user 2.1% system 0.0% nice 0.0% iowait 97.0% idle
    CPU1 states: 2.0% user 0.1% system 0.0% nice 0.0% iowait 97.1% idle
    Mem: 1029256k av, 1019056k used, 10200k free, 0k shrd, 32396k buff
    506132k actv, 48604k in_d, 11064k in_c
    Swap: 1020088k av, 474904k used, 545184k free 98560k cached

    I found that a user were using mysql_pconnect, with this command the connection to mysql will not be closed when script end. This will using resources and accumulate to nearly maximum limit of the server and the server will go down. Only reboot at power switch will fix this when it crash.

    Then I go to php.ini and turn
    mysql.allow_persistent = Off
    and restart apache. It's now look like the server operate very good. I got mysql process below 20 almost all the time. I hope that it will help someone who are in the same situation like me. :)
     
  2. casey

    casey Well-Known Member

    Joined:
    Jan 17, 2003
    Messages:
    2,303
    Likes Received:
    0
    Trophy Points:
    36
    Location:
    If there is trouble, it will find me

Share This Page