Results 1 to 8 of 8
  1. #1
    Join Date
    Jan 2006
    Location
    Toronto, Canada
    Posts
    269

    mysql has 182% cpu usage

    I am using lighttpd php and mysql.
    How to lower the cpu usage?
    What's the best way to monitor mysql usage?

    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

  2. #2
    You should find out what is causing the high CPU usage. Take a look at the MySQL process list, which you can view from within the mysql client program with 'show processlist;' or from your shell with the 'mysqladmin processlist' command.
    Randall Blecher
    Systems Administrator
    WalkerTek Interactive Marketing
    www.walkertek.com

  3. #3
    Join Date
    Oct 2000
    Location
    Israel
    Posts
    1,286
    When mySQL is using high CPU, then it's usually problems with the queries. Use LIMIT to make your query results smaller and JOIN to improve efficiency. Also, check your indexes.

  4. #4
    Join Date
    Apr 2005
    Location
    Cochin
    Posts
    2,446
    You must find your slow queries and optimize them. Also optimize the way how the mysql server works to minimize the cpu usage
    Sam
    Supportlobby.com - Expertise in Windows/Linux server support, IaaS and PaaS Management
    Spiralbean.com - Custom Software Development
    Email: exec @ activelobby.net | Skype: unni_active

  5. #5
    MySQL has a feature that allows you to log slow running queries to a file. To enable you just need to add some lines to your my.cnf file, and restart. Add the following:
    Code:
    log-slow-queries = /var/log/mysql/mysql-slow.log
    long_query_time = 1
    The above will log queries taking longer than one second to the specified log file.

  6. #6
    Join Date
    Apr 2005
    Location
    Holland
    Posts
    124
    you can also try mysqltop tool ;-)

    Regards,
    Aleks

  7. #7
    Join Date
    Mar 2007
    Location
    Phoenix, AZ
    Posts
    132
    I think you meant mtop
    Cheers,
    Sivanandhan, P. (a.k.a. apsivam)
    My Blog Site

  8. #8
    Quote Originally Posted by apsivam View Post
    I think you meant mtop
    There is also a similar program called mytop.
    Randall Blecher
    Systems Administrator
    WalkerTek Interactive Marketing
    www.walkertek.com

Posting Permissions

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