Mysql – High load and iowait on MySQL database server leads to slow MySQL INSERTS

hard driveMySQLperformance

I have a MySQL database server runnuing on Ubuntu 12.10 with 64GB RAM, 2×3 TB SATA 6 Gb/s HDD 7200 rpm and software RAID 1 and an Intel Core i7-3930K.
The database server is accessed over a local network with a dedicated 1 GBit ethernet card.
The database is around 50 GB big and is the master in a replication setup.

IMO, there are two problems that lead to slow MySQL querying:

  1. The load is always relatively high (>2) even when the db server is idle (it's not a big problem since the processor has 12 cores but it doesn't seem right)
  2. top shows that around 95% of the system is idle, <1% is used 5% is waiting (see following screenshot)

iotop --only shows that most of the disk IO is produced by jdb2/md2-8 and not mysqld – so mysqld shouldn't be the problem – but why is jdb2/md2-8 using up so many ressources?

cat /proc/mdstat outputs the following:

My questions are:
What causes the slow MySQL performance?
Is it the iowait? What causes the iowait?
Is it the RAID 1 – Is it the used harddisk?

Any help is greatly appreciated!

Best Answer

You are running a log-heavy database on just about the slowest disks out there. The reason you're seeing jdb2 on such high iowaits is because it's having a hard time keeping up writing the ext4 journals to disk

Either change disks to something that can keep up (SSD's come to mind, allthough regular SAS disks with a battery cache would work) and/or start tuning stuff. There are plenty of documentation out there when it comes to filesystem tuning in SQL environments.

A good starting point is here: http://dev.mysql.com/doc/refman/5.0/en/disk-issues.html