Summary: Four Io Scheduling Algorithms in Linux 2.6 kernel

Source: Internet
Author: User

In Linux 2.6, there are four Io scheduling algorithms. The following is a summary:

1) Noop
The Noop algorithm is completely written as no operation. This algorithm implements the simplest FIFO queue. All IO requests are operated in the first-to-last-order. The reason is that Noop merges adjacent IO requests on the basis of FIFO, rather than completely satisfying IO requests according to the first-in-first-out rules. Noop assumes that I/O requests are optimized or rearranged by the driver or device (just like what a smart controller does ). In some SAN environments, this option may be the best choice. Noop is not so worried about Io. It processes all IO requests in the form of a FIFO queue. By default, it is considered that Io will not have performance problems. This also makes
You don't have to worry about CPU. Of course, you will be very worried about using this Scheduler for complex application types.

2) deadline Scheduler
Based on CFQ, deadline solves the extreme situation of Io request starvation. In addition to the CFQ Io sorting queue, deadline provides a FIFO queue for read Io and write Io respectively. The maximum waiting time for a read-first-in-first-out queue is 500 ms, and the maximum waiting time for a write-in-first-out queue is 5 s. The priority of IO requests in the FIFO queue is higher than that in the CFQ queue, while that in the Read/FIFO queue is higher than that in the write FIFO queue. The priority can be expressed as follows:

FIFO (read)> FIFO (write)> CFQ
The deadline algorithm ensures minimum latency for established IO requests. Therefore, it is suitable for DSS applications.

3) anticipatory Scheduler
CFQ and deadline focus on satisfying fragmented IO requests. Continuous IO requests, such as sequential reads, are not optimized. To meet the mixed scenarios of random I/O and sequential I/O, Linux also supports the anticipatory scheduling algorithm. Based on deadline, anticipatory sets 6 ms for each read Io

. If the OS receives read IO requests from neighboring locations within these 6 ms
Anticipatory scheduler (AS) was once the IO scheduler of Linux 2.6 kernel. The Chinese meaning of anticipatory is "expected, expected". This word does reveal the characteristics of this algorithm. In short, when I/O occurs, if another process requests Io operations, a default 6-millisecond time will be generated to guess what the next process request Io will do. This will cause a relatively large latency for instant reading, which is very bad for database applications, and good for Web servers. This algorithm can also be simply understood as for low-speed disks, because the "Guess" is actually designed to reduce the head moving time.

4) CFQ
The CFQ algorithm is fully written as completely fair queuing. This algorithm sorts the IP addresses of IO requests, rather than responding in the first and second order.
In traditional SAS disks, disk seek takes a vast majority of I/O response time. The starting point of CFQ is to sort the IO addresses to meet as many IO requests as possible with as few disk rotations as possible. In the CFQ algorithm, the throughput of the SAS disk is greatly increased. However, the disadvantage of Noop is that the first-come Io request is not necessarily satisfied, and it may starve to death.

Completely fair queuing (CFQ, fully fair queue) replaces anticipatory schedory in 2.6.18 to become the default Io schedory of Linux kernel. CFQ maintains an IO queue for each process, and the IO requests sent by each process are processed by CFQ in a round robin manner. That is, it is fair for every Io request. This makes CFQ suitable for discrete read applications (eg: OLTP dB ). In the Enterprise Linux release I know, SuSE Linux seems to be the first to use CFQ by default.

The algorithm for viewing and modifying the IO scheduler is very simple. Suppose we want to operate SDA as follows:
CAT/sys/block/SDA/queue/schedue
Echo "CFQ">/sys/block/SDA/queue/schedue

Summary:
1 CFQ and deadline focus on meeting fragmented IO requests. Continuous IO requests, such as sequential reads, are not optimized. To meet the mixed scenarios of random I/O and sequential I/O, Linux also supports the anticipatory scheduling algorithm. Based on deadline, anticipatory sets a 6 ms wait time window for each read Io. If the OS receives a read Io request from the adjacent location within these 6 ms, it can be immediately satisfied.

The selection of Io scheduler algorithms depends on both hardware features and application scenarios.
In traditional SAS disks, CFQ, deadline, and anticipatory are both good choices. For dedicated database servers, deadline delivers good throughput and response time. However, in emerging solid state disks such as SSD and fusion Io, the simplest Noop may be the best algorithm, because the optimization of the other three algorithms is based on shortening the seek time, SSD does not have the so-called tracing time and the IO response time is very short.

2. For database applications, anticipatory schedory has the worst performance. Deadline performs better in the DSS environment than CFQ, while CFQ performs better in combination. It is no wonder that the default Io scheduler of RHEL 4 is set to CFQ. While RHEL 4 is much better than RHEL 3.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.