In order to eek out as much performance from Linux servers as possible, learn how to change your I/O scheduler to meet your needs.
The Linux I/O scheduler controls the way the kernel commits read and writes to disk. Since the 2.6 kernel, administrators have been able to change the scheduler, so they can customize their platforms to perfectly suit their needs.
There are three schedulers to choose from, and each one has its benefits. Those schedulers are:
- CFQ (cfq): the default scheduler for many Linux distributions; it places synchronous requests, submitted by processes, into a number of per-process queues and then allocates timeslices for each of the queues to access the disk.
- Noop scheduler (noop): the simplest I/O scheduler for the Linux kernel based on the First In First Out (FIFO) queue concept. This scheduler is best suited for SSDs.
- Deadline scheduler (deadline): attempts to guarantee a start service time for a request.
When you want to squeeze the most performance out of your Linux-powered machines, this might be one of the areas you turn. Fortunately, it is quite simple to change the scheduler that powers I/O. Let me show you how.
SEE: 2017: The year Linux will reach 5% market share (TechRepublic)
Finding out which scheduler you have
The first thing you need to do is find out which scheduler is handling I/O on your system. This is done from the command line, and you must know the name of your disk. For simplicity sake, I'll assume the disk is question is sda. With that information in hand, open a terminal window and issue the following command:
The results of the command will display the current running scheduler (Figure A).
Changing your scheduler
You can change your scheduler in two ways: on the fly or persistently. If you change the scheduler on the fly, it can revert to the default scheduler (after a reboot). You might want to do an on the fly change first, to see which scheduler brings about the best performance for your needs.
Say you want to change to the noop scheduler on the fly. To do this, you would issue the following command:
sudo echo noop > /sys/block/hda/queue/scheduler
You can change noop to cfq, or deadline.
This change can be done without having to reboot your machine. Once changed, the I/O scheduler will switch and (hopefully) you'll see a performance increase (again, depending upon your needs).
If you want to change the scheduler to be persistent, you must do this within the GRUB configuration file. To do that, issue the command sudo nano /etc/default/grub and then change the line:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash elevator=noop"
Again, you can change noop to whatever scheduler you need. If you make this change after you do an on the fly change, you won't have to do a reboot to have the new scheduler take effect.
That's all there is to it.
- 5 data center-ready Linux distributions (TechRepublic)
- How to get all the information you need about your Linux machine with a single command (TechRepublic)
- How to install malware detection and antivirus on CentOS 7 (TechRepublic)
- How to install the Ansible server management system on Ubuntu (TechRepublic)
- Linux 2017: With great power comes great responsibility (ZDNet)
- Securing Linux Policy (Tech Pro Research)