Why mysql application is utilizing 100% cpu?

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux 5
  • Red Hat Enterprise Linux 6

Issue

  • Top command is reporting 100% cup is being utilized by mysql.

Resolution

  • Database tuning is require. indexing etc....

Root Cause

  • Slow query logs were reporting that some queried were running for long time ( Query time was increased because of no of rows mysql had to examined).

  • Example:

# Query_time: 33.400307  Lock_time: 2.295032 Rows_sent: 3  Rows_examined: 3420581
# Query_time: 33.408299  Lock_time: 2.298814 Rows_sent: 3  Rows_examined: 3420581
# Query_time: 33.424737  Lock_time: 2.293420 Rows_sent: 3  Rows_examined: 3420581
# Query_time: 33.445227  Lock_time: 2.283884 Rows_sent: 3  Rows_examined: 3420581
# Query_time: 33.465387  Lock_time: 2.304770 Rows_sent: 3  Rows_examined: 3420581
  • If such queries runs, obviously it is expected that it will hit CPU eventually.

Diagnostic Steps

  • Checked mysql slow query logs.
  • Checked mysql logs.

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments