Skip to content

Tuning Linux I/O Scheduler for SSDs

I/O Scheduler

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.

Tuning

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

permanent

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

Disclaimer
  1. License under CC BY-NC 4.0
  2. Copyright issue feedback me#imzye.me, replace # with @
  3. Not all the commands and scripts are tested in production environment, use at your own risk
  4. No privacy information is collected here
Try iOS App