Mysql 8 – % CPU Wait

MySQLmysql-8.0

Is it normal in Mysql 8 to have a high percentage of CPU wait?

(see image)

enter image description here

Best Answer

A CPU core being in an "IO wait" state inthe OS means that there are tasks that could be assigned for that core to work on, but they are all waiting for an IO operation to complete.

In your case displayed there, you have only one task that really busy and that is mysql, and it is spending most of its time waiting for IO operations to complete. This is not unusual. If you run cat /dev/sda > /dev/null you'll see the IO wait count jump up, more so if you run that a couple of times concurrently.

It may indicate that ere are things you could optimise to speed up your application(s) considerably:

  • if the delay is in making updates, then getting faster drives
  • if the delay is due to queries performing scans of large tables or indexes, then by improving the queries or your index choices
  • if the delay is mostly due to read IO and there isn't much scanning going on then your common working set may be larger than can fit in memory and adding/allocating more RAM may be helpful
  • if the delay is a mix or read/write or mostly random access read, then improving IO latency would be useful (the data rates displayed there are not high given the drive is 100% busy, so I assume you have a traditional drive and there is significant random access happening, so upgrading to SSD may help a lot)

Of course if everything is responding with acceptable speed this may be normal for your app and system and you might not need to alter anything yet (though it is always worth taking a look at index use and so forth, and proactively monitoring CPU & IO metrics, so you can pre-emptively spot and perhaps fix future problems that will happen as your use scales up before they actually become significant).

Related Question