How to Change the Linux I/O Scheduler to Tune Performance

Summary: To squeeze as much performance out of your Linux server as possible, learn how to change the I/O scheduler to suit your needs. Linux I/O Scheduler The Linux I/O scheduler controls how the kernel submits read and write requests to disk. Since the 2.6 kernel, administrators have been able to change this scheduler, so they can customize their platform to exactly suit their needs.

To squeeze as much performance out of your Linux server as possible, learn how to change the I/O scheduler to suit your needs.

Linux I/O Scheduler The Linux I/O scheduler controls how the kernel submits read and write requests to disk. Since the 2.6 kernel, administrators have been able to change this scheduler, so they can customize their platform to exactly suit their needs.

There are three schedulers to choose from, each with its advantages. These schedulers are:

CFQ (Completely Fair Scheduler) (cfq): It is the default scheduler on many Linux distributions; Allocate time slices to access the disk.
Noop scheduler (noop): The simplest I/O scheduler in the Linux kernel based on the concept of a first-in, first-out (FIFO) queue. This scheduler is best for SSDs.
Deadline Scheduler (deadline): Attempts to guarantee the start of service time for requests.
This is probably one of the things you do when you want to get the best performance out of your Linux machine. Fortunately, changing the I/O scheduler is very simple. Let me show you how.

Find out which scheduler
you have The first thing you need to do is find out which scheduler is handling the I/O on your system. This is done from the command line, you must know the name of the disk. For simplicity, I assume the disk is sda. With this information, open a terminal window and enter the following command:

cat /sys/block/sda/queue/scheduler
The result of this command will show the currently running scheduler (below).

Elementary OS Loki runs the deadline scheduler.
Elementary OS Loki runs the deadline scheduler.

Changing your scheduler
You can change your scheduler in two ways: immediate or permanent. If you change the scheduler on the fly, it will revert to the previous default scheduler after a reboot. You may want to make on-the-fly changes first to see which scheduler gives the best performance for your needs.

Say you want to change to the noop scheduler on the fly. To do this, enter the following command:

sudo echo noop > /sys/block/hda/queue/scheduler
You can change noop to cfq or deadline.

This change can take effect without restarting the computer. Once changed, the I/O scheduler will switch and (hopefully) you will see a performance improvement (again, depending on your needs).

If you want to change the scheduler to be permanent, you must do so in the GRUB configuration file. To do this, type sudo nano /etc/default/grub, then change the following line:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
to

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash elevator=noop"
Again, you can change noop to whatever scheduler you want. If you are using on-the-fly modification, you don't have to restart for the new scheduler to take effect.

These are the methods for modifying the scheduler.

Make an informed choice
You should do your research to find out what scheduler is best for your particular situation. To learn more about each scheduler, check out these wiki pages: CFS, Noop, and Deadline.

The original release time is: 2017-02-06

This article is from Yunqi Community Partner "Linux China"

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326209182&siteId=291194637