Change disk I/O scheduler on the fly

diskThe Linux kernel supports 4 I/O schedulers for disks:

  • Deadline: minimizes disk seeks in order to provide best possible response time Default on Ubuntu.
  • Anticipatory: Adds an anticipation heuristic on top of deadline I/O scheduler. It spends a few milliseconds in anticipation that new requests in the same area might appear. However, if there are no further requests, the time is wasted in waiting. Not very common.
  • Completely Fair Queueing: Assigns the requests to multiple queues based on the process requesting the I/O. Services the queues round-robin. Default on RHEL.
  • Noop: No optimization of disk seeks.

As you can understand from the working principle of each scheduler, they fit the bill or different use-cases. The good part is they are per-disk based schedulers and can be changed on the fly.

You can, of course, change the behaviour of the kernel and compile it from scratch. All you need to set is any one of the following  kernel config options:

CONFIG_DEFAULT_DEADLINE
CONFIG_DEFAULT_CFQ
CONFIG_DEFAULT_NOOP

and set

CONFIG_DEFAULT_IOSCHED="scheduler_of_choice"

To check the scheduler used for a particular disk (e.g. sda):

$ cat /sys/block/sda/queue/scheduler 
noop [deadline] cfq

To set it to cfq at runtime:

$ echo cfq | sudo tee /sys/block/sda/queue/scheduler

Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s