Page 1 of 1

MySQL using 103% CPU

Posted: Sun Jul 11, 2010 9:52 am
by JKM
The MySQL process is using a lot of CPU time, even though theres only one query listed after writing SHOW PROCESSLIST;

Code: Select all

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
24234 mysql     20   0  461m 166m 6152 S   103  2.1  10:08.92 mysqld

Code: Select all

Server version: 5.0.51a-24+lenny4-log (Debian)
mysql> SHOW PROCESSLIST;
+------+----------+------------------+----------+---------+------+-------+------------------+
| Id   | User     | Host             | db       | Command | Time | State | Info             |
+------+----------+------------------+----------+---------+------+-------+------------------+
|  902 | mysqlusr | 11.11.11.1:33582 | mydatabs | Sleep   |  632 |       | NULL             |
| 1328 | root     | localhost        | NULL     | Query   |    0 | NULL  | show processlist |
+------+----------+------------------+----------+---------+------+-------+------------------+
2 rows in set (0.00 sec)
I'm running Debian GNU/Linux 5.0, and I'm having 8 * Intel Xeon X5450 @ 3GHz and 6 GB RAM. I've tried to restart the mysql process, and reboot my machine. It holds at like 1% in 5 minutes, but suddently, it's up to 90-120%, and it stays that way until i restart the mysql process.

Re: MySQL using 103% CPU

Posted: Sun Jul 11, 2010 5:12 pm
by JakeJ
Divide by 8 and you have your real answer.

If you use the top command then press 1, it will break out each CPU. As it stands, it can go up to 800%.

Re: MySQL using 103% CPU

Posted: Tue Jul 13, 2010 2:22 am
by VladSun
Run "uptime"
Its output looks like this:

Code: Select all

uptime
 10:21:16 up  1:05,  2 users,  load average: 0.57, 0.45, 0.52
The three load average values should be less than the number of CPUs you have.

Re: MySQL using 103% CPU

Posted: Tue Jul 13, 2010 7:04 pm
by JKM

Code: Select all

uptime
 02:02:16 up 7 days, 16:53,  3 users,  load average: 2.40, 1.96, 0.79
@JakeJ: java is using ~9% and it's running a pretty big program, so I think 103% is pretty high no matter what :p

Re: MySQL using 103% CPU

Posted: Tue Jul 13, 2010 7:07 pm
by JakeJ
You're right, 103 still seems to be pretty high, but I've also read that it doesn't always report accurately. Look around for some discussion on the matter. There are some third party monitoring tools that are more accurate.