Introduction to Linux Io scheduler Algorithms

Source: Internet
Author: User
Linux I/O scheduler algorithm introduction from: http://www.realzyy.com /? P = 984

Io sched is a method used by the operating system to determine the order of Io operations submitted on Block devices. There are two purposes: Improving Io throughput and reducing Io response time. However, Io throughput and IO response time are often in conflict. To balance the two as much as possible, the IO scheduler provides multiple scheduling algorithms to adapt to different Io request scenarios. Deanline is the most advantageous Algorithm for random read/write scenarios such as databases. Then, we quickly scanned several Io scheduling algorithms provided by the Linux 2.6 kernel in a simple to complex order.

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.
Assume that there are the following Io request sequences:
100,500,101, 1000
Noop will meet the requirements in the following order:
100 (101), 10

2. 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.
Assume that there are the following Io request sequences:
100,500,101, 1000
CFQ will meet the requirements in the following order:
100,101,500,100, 56

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.

3. Deadline
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

4. Anticipatory
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 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.

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

Related Article

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.