Linux I/O disk elevator

What is I/O elevator ?


From 2.6 kernel Linux employs a new I/O elevator model. While the Linux kernel 2.4 used a single, general-purpose I/O elevator, kernel 2.6 offers the choice of four elevators. Because the Linux operating system can be used for a wide range of tasks, both I/O devices and workload characteristics change significantly. A notebook computer probably has different I/O requirements than a 100,000 user database system. To accommodate this, four I/O elevators are available.


Anticipatory

The anticipatory I/O elevator was created based on the assumption of a block device with only one physical seek head (for example a single SATA drive). The anticipatory elevator uses the deadline mechanism described in more detail below plus an anticipation
heuristic. As the name suggests, the anticipatory I/O elevator “anticipates” I/O and attempts to write it in single, bigger streams to the disk instead of multiple very small random disk accesses. The anticipation heuristic may cause latency for write I/O. It is clearly tuned for high throughput on general purpose systems such as the average personal computer. Up to kernel release 2.6.18 the anticipatory elevator is the standard I/O scheduler. However most Enterprise Linux distributions default to the CFQ elevator.

Complete Fair Queuing (CFQ)

The CFQ elevator implements a QoS (Quality of Service) policy for processes by maintaining per-process I/O queues. The CFQ elevator is well suited for large multiuser systems with a lot of competing processes. It aggressively attempts to avoid starvation of
processes and features low latency. Starting with kernel release 2.6.18 the improved CFQ elevator is the default I/O scheduler. Depending on the system setup and the workload characteristics, the CFQ scheduler can slowdown a single main application, for example a massive database with its fairness oriented algorithms.

Deadline

The deadline elevator is a cyclic elevator (round robin) with a deadline algorithm that provides a near real-time behavior of the I/Osubsystem. The deadline elevator offers excellent request latency while maintaining good disk throughput. The implementation of the deadline algorithm ensures that starvation of a process cannot occur.

NOOP

NOOP stands for No Operation, and the name explains most of its functionality. The NOOP elevator is simple and lean. It is a simple FIFO queue that does not perform any data ordering. NOOP simply merges adjacent data requests, so it adds very low processor overhead to disk I/O. The NOOP elevator assumes that a block device either features its own elevator algorithm such as TCQ for SCSI, or that the block device has no seek latency such as a flash card.

With the Linux kernel release 2.6.18 the I/O elevators are now selectable on a per disk subsystem basis and no longer need to be set on a per system level.


How to set the default I/O Elevator in the kernel.

By default the CFQ will be the default elevator for the redhat system, If you like to change that you need to recompile you kernel by
selecting under ” Enable the block layer  —> IO Schedulers  —> select the scheduler from the list and recompile the kernel.

Kernel IO default scheduler


Changing the I/O scheduler for particular harddrive

Since the i/o elevator is plugabble it is possible to setup for per disk basic. For example if you like to setup deadline scheduler for /dev/sdb

  • @server1:.+block/sdb/queue# cat scheduler
  • noop anticipatory deadline [cfq]
  • @server1:.+block/sdb/queue# echo deadline > scheduler
  • @server1:.+block/sdb/queue# cat scheduler
  • noop anticipatory [deadline] cfq

IO elevator

To make the scheduler permanent, you need to edit the /boot/grub.conf file and add elevator=noop in kernel line.

Useful links :

Redhat i/o elevator guide