Home >System Tutorial >LINUX >One way to improve server performance: Modify the Linux I/O scheduler

One way to improve server performance: Modify the Linux I/O scheduler

WBOY
WBOYforward
2024-01-15 22:42:061323browse

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

更改 Linux I/O 调度器来改善服务器性能

Linux I/O Scheduler()Controls the way the kernel submits read and write requests to the 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 own advantages. These schedulers are:

  • CFQ (Completely Fair Scheduler())(cfq): It is a feature of many Linux distributions The default scheduler for Windows version; it places synchronization requests submitted by processes into multiple process queues, and then allocates a time slice to each queue to access disk.
  • Noop scheduler (noop): The simplest I/O scheduler in the Linux kernel based on the first-in-first-out (FIFO) queue concept. This scheduler works best with SSDs.
  • Deadline scheduler (deadline): Try to guarantee the start service time of the request.

This is probably one of the things you do when you want to get the best out of your Linux machine. Fortunately, changing the I/O scheduler is very simple. Let me tell 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'll assume the disk is sda. Based on this information, open a terminal window and enter the following command:

cat /sys/block/sda/queue/scheduler

The results of this command will display the currently running scheduler (picture below).

更改 Linux I/O 调度器来改善服务器性能

Elementary OS Loki runs the deadline scheduler.

Change your scheduler

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

Speaking of your immediate need to change to the noop scheduler. 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 this in the GRUB configuration file. To do this, enter sudo nano /etc/default/grub and modify the following lines:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"

arrive

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash elevator=noop"

Again, you can change noop to whatever scheduler you need. If you are using on-the-fly modification, you do not have to restart for the new scheduler to take effect.

These are the methods to modify the scheduler.

Make a wise 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 above is the detailed content of One way to improve server performance: Modify the Linux I/O scheduler. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:linuxprobe.com. If there is any infringement, please contact admin@php.cn delete