Skip to content

Tuning Linux I/O Scheduler for SSDs

homepage-banner

I/O Scheduler

I/O Scheduler is an essential component of the Linux kernel that governs the order in which Input/Output (I/O) requests are processed. It determines how the system responds to disk I/O requests and manages the disk access schedule. Choosing an appropriate I/O scheduler can significantly impact system performance. Therefore, it is crucial to understand how I/O schedulers work and how they can be optimized.

Different Types of I/O Schedulers

There are several types of I/O schedulers available in the Linux kernel, including the Completely Fair Queuing (CFQ), Deadline, and NOOP schedulers. CFQ is the default scheduler in most Linux distributions and uses a round-robin algorithm to allocate disk access to various processes. The Deadline scheduler, on the other hand, uses a deadline-based algorithm to prioritize I/O requests based on their deadlines. Finally, the NOOP scheduler is a simple FIFO (First In, First Out) algorithm that processes I/O requests in the order they arrive.

NOOP

NOOP is the simplest of all I/O schedulers. It just sends data to a FIFO queue, merges requests to save on disk seeks and passes data on. It can be useful to use NOOP and PostgreSQL in highly virtualized setups where the underlying host system does all the magic.

CFQ

CFQ is short for “Completely Fair Scheduler”. The idea of CFQ is give all processes belonging to the same priority class same sized time slices. A process performing sequential I/O might receive a lot more bandwidth than a process doing random I/O (in a database random I/O can frequently happen during OLTP-workloads).

CFQ is the default value and usually a good idea for desktop application, which should stay responsive. It is not necessarily a good idea for database servers such as PostgreSQL.

Deadline

The deadline scheduler tries to make sure that no process can suffer from starvation. The kernel imposes a deadline for each I/O. Practical tests have shown that using deadline is practically always faster than relying on the default (= CFQ). Actually I have not seen a case personally, in which CFQ was better than deadline. In many cases it makes no difference but I have never encountered a scenario in which deadline was the worse choice.

Choosing the Right I/O Scheduler

Choosing the right I/O scheduler can be challenging because it depends on several factors, such as disk usage patterns, workload characteristics, and hardware specifications. For instance, if the system is primarily running database applications with high read/write requests, the Deadline scheduler may be the best option. On the other hand, if the system is running a web server with a mix of read/write operations, the CFQ scheduler may be a better fit. It is also essential to keep in mind that the performance of I/O schedulers can vary depending on the type of storage. For example, solid-state drives (SSDs) may perform better with the NOOP scheduler than with CFQ or Deadline.

Change it once

### for Debian, Ubuntu and RHEL 4,5,6,7
echo noop | sudo tee /sys/block/sda/queue/scheduler

### for RHEL 8
echo none | sudo tee /sys/block/sda/queue/scheduler

Change it permanently

Edit /etc/default/grub

### Add "elevator=noop" to the GRUB_CMDLINE_LINUX_DEFAULT line.
sudo update-grub

Reference

  • https://dzone.com/articles/tuning-linux-io-scheduler-ssds
  • https://access.redhat.com/solutions/109223
Leave a message