mysql has 182% cpu usage

Discussion in 'Site & Server Administration' started by heropage, Dec 20, 2007.

  1. #1
    Why mysql get so high cpu usage?
    Is there any way I can monitor mysql, like mytop?

    top - 10:39:48 up 10 days, 35 min, 1 user, load average: 8.22, 9.38, 8.50
    Tasks: 132 total, 5 running, 127 sleeping, 0 stopped, 0 zombie
    Cpu(s): 73.5%us, 22.3%sy, 0.0%ni, 2.1%id, 0.0%wa, 0.1%hi, 2.0%si, 0.0%st
    Mem: 2075000k total, 1919256k used, 155744k free, 113660k buffers
    Swap: 2031608k total, 56k used, 2031552k free, 1177200k cached

    PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
    21899 mysql 20 0 200m 53m 4752 S 182 2.6 8100:18 mysqld
    2548 lighttpd 20 0 20288 16m 680 S 19 0.8 878:33.76 lighttpd
    9759 lighttpd 20 0 23168 7880 3048 S 10 0.4 8:50.96 php-cgi
    30959 lighttpd 20 0 23164 7896 3096 S 10 0.4 11:40.95 php-cgi
    9732 lighttpd 20 0 23204 7544 2664 S 8 0.4 8:59.42 php-cgi
    10671 lighttpd 20 0 23248 7612 2664 S 8 0.4 4:51.95 php-cgi
    9769 lighttpd 20 0 23312 8012 3048 S 7 0.4 8:55.61 php-cgi
    9771 lighttpd 20 0 23104 7312 2584 S 7 0.4 8:50.33 php-cgi
    10601 lighttpd 20 0 23336 8032 2996 S 7 0.4 4:56.21 php-cgi
    31091 lighttpd 20 0 23064 7860 3100 S 7 0.4 11:30.69 php-cgi
    9782 lighttpd 20 0 23116 7880 3060 S 7 0.4 8:57.46 php-cgi
    8559 lighttpd 20 0 23396 7780 2668 R 6 0.4 6:43.16 php-cgi
     
    heropage, Dec 20, 2007 IP
  2. InFloW

    InFloW Peon

    Messages:
    1,488
    Likes Received:
    39
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Sounds like you got some nasty queries going on there. mytop would be one way to see the queries that are going through mysql at that very moment.

    What you'd want to do it look further into this is put the following in my.cnf

    log-slow-queries


    Now it'll put all slow queries into a file hostname-slow.log in /var/lib/mysql or wherever your mysql files are being stored. So if you have slow queries showing up there then you should look to optimizing those queries by either changing them or adding missing indexes and things of that nature.
     
    InFloW, Dec 20, 2007 IP
  3. chriswick

    chriswick Peon

    Messages:
    907
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    0
    #3
    looks fishy to me, what dynamic site are you running MySQL on?
     
    chriswick, Dec 22, 2007 IP
  4. hosting.network

    hosting.network Banned

    Messages:
    285
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    you need to update mysql

    if you cant do .. Pm me
     
    hosting.network, Dec 24, 2007 IP
  5. inworx

    inworx Peon

    Messages:
    4,860
    Likes Received:
    201
    Best Answers:
    0
    Trophy Points:
    0
    #5
    You need mysql optimization. Seems you're peaking Memory usage as well. Upgrading RAM might solve the problem to a extent but not completely.
     
    inworx, Dec 24, 2007 IP
  6. mellow-h

    mellow-h Peon

    Messages:
    750
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Have you tried Enabling Query cache of your mysql system? Caching may help you to reduce the load?
     
    mellow-h, Dec 25, 2007 IP
  7. InFloW

    InFloW Peon

    Messages:
    1,488
    Likes Received:
    39
    Best Answers:
    0
    Trophy Points:
    0
    #7
    What exactly are you basing this off of? What happens if they're running MySQL 5?

    Silly post...
     
    InFloW, Dec 25, 2007 IP
  8. showmoney.net

    showmoney.net Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    You could edit code in your *.cgi, I think your source code *.cgi never close query in mysql
     
    showmoney.net, Dec 27, 2007 IP