Testing MySQL sequential IO performance with different IO schedulers - Part 1

June 23rd, 2008 by atomic

Testing MySQL sequential IO performance with different IO schedulers - Part 1

I stumbled upon an interesting article discussing the different Linux I/O schedulers that are available in the 2.6 kernel, and also discussing some of the deficiencies of the 2.4 “Linus elevator” I/O scheduler.

The default scheduler as of Kernel 2.6.18 is the “Completely fair queuing” scheduler, or CFQ. The previous default was the anticipatory scheduler between 2.6.0 and 2.6.17. Also available is a buffed-up version of the 2.4 scheduler called the deadline scheduler, and a “noop” scheduler. This article has a great discussion on what these schedulers mean for databases at a higher level.

Although old, some documentation in the kernel statesĀ  that database workloads should typically use the deadline scheduler. This tuning guide for Oracle on Linux gives, without much explanation, the same advice .

I don’t have the time at the moment to do a full analysis (hence part 1), but I did some quick tests and already got some pretty surprising results. I’m hoping to see if anyone else has done some tests along these lines that can comment further.

The test

I have a 140GB table sitting on a test machine with a simple 320GB SATA drive.

Changing the scheduler in newer kernels is a simple tunable parameter. You can change it to the deadline scheduler for your sda device, for example, as follows:

echo deadline > /sys/block/sda/queue/scheduler

I ran a simple count(*) on one of the partitions, 13GB in size, to see if there was a measurable difference between the schedulers. Memory size on this system is 4GB.

These are the results I got on an otherwise idle machine. The CFQ and anticipatory results were very consistent, almost to the second each time, while the deadline and no-op schedulers fluctuated as much as 50s per test. Not sure at this point why this is the case.

Scheduler
Average runtime (s)
Average Throughput (MiB/s)
CFQ
303
43.04
Anticipatory
370
35.4
Deadline
492
26.5
No-op
471
27.6



Now, these results come with the following caveats:

- These are not extensive, robust benchmarks, they’re just a few tests I ran against my very specific workload. I encourage people to try the different schedulers on different workloads and hardware and share results!
- These are test results with a large, sequential I/O workload that is very different from the random I/O intensive tests that most people are interested in.
- These are test results against a single ATA drive. These results are probably irrelevant in a hardware RAID context

In a future blog post, I will try to dig a bit deeper into these results and try the tests against hardware and software RAID. What i think can be taken from this already, and the referenced articles, is that CFQ should probably be used if your kernel has direct knowledge of the physical layout of your disks, eg. through LVM. Otherwise, deadline or even noop is probably your best bet if you are using hardware RAID, putting the burden on the hardware to decide how best to execute reads and writes.

Posted in mysql, performance |

3 Responses

  1. Log Buffer #103: a Carnival of the Vanities for DBAs Says:

    [...] Tomic has the first part of a series on testing MySQL sequential IO performance with different IO schedulers in the Linux kernel. Tis is fine-tuning, and it can make a real [...]

  2. Peter Zaitsev Says:

    Well RAID level would matter a lot here. Smart RAID may make NOOP better though CFQ is often good choice for database workloads.

  3. atomic Says:

    @Peter: Yes, I think these results are mostly just for interest and gaining an understanding of the schedulers. I hope it also convinced anyone that is still using 2.4 kernel to upgrade :)

    I didn’t expect to see such a difference with such a simple environment but it just goes to show how important it is to always performance test everything and never make assumptions!

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.