In this era of multi-core, multi-gigaherz CPUs, traditional platter-based hard disks remain the “weak link” of modern machines. And they are here to stay: while SSDs are rapidly evolving and their prices are dropping, the cost per GB of storage space offered by HDDs is simply unmatched by their flash brothers.
The work of the I/O scheduler, a key component of every operating system, is precisely to extract as much juice as possible from these aging HDDs. Linux has not only one or two, but no less then four I/O schedulers at your disposition. Here is a brief explanation of these schedulers (taken from this Red Hat article):
- the Anticipatory scheduler introduces a controlled delay before dispatching the I/O to attempt to aggregate and/or re-order requests improving locality and reducing disk seek operations. This algorithm is intended to optimize systems with small or slow disk subsystems;
- the Completely Fair Queuing (CFQ) scheduler maintains a scalable per-process I/O queue and attempts to distribute the available I/O bandwidth equally among all I/O requests;
- the Deadline scheduler uses a deadline algorithm to minimize I/O latency for a given I/O request;
- the Noop scheduler is a simple FIFO queue, and it assumes performance of the I/O has been or will be optimized at the block device.
As the I/O scheduler is a critical component of an operating system, it is legitimate to wonder which is the best for high performances in common workloads. This turn to be a complex question with a complex answer, and it is heavily dependent not only on the kind of workload that you throw at the disks, but also on the expected system behavior. For example, in a real time system the deadline scheduler can be the best choice because it pose a limit to maximum latency. However, on a throughput-oriented system it can be sub-optimal.
So, keeping in mind that this article do not want (and it can not) to elect the absolute winner in the I/O champ, let give a look at how these I/O schedulers fare in common workloads.