IO scheduling algorithm

Source: Internet
Author: User

Selection of IO scheduling algorithm

A) I/O Scheduler summary

1) When the data block is written to the device or read from the device, the request is placed in a queue waiting to be completed.

2) Each block device has its own queue.

3) The I/O Scheduler is responsible for maintaining the order of these queues to make more efficient use of the media. The I/O scheduler turns unordered I/O operations into ordered I/O operations.

4) The kernel must first determine how many requests are in the queue before it starts scheduling.

II) 4 Algorithms for I/O scheduling

1) CFQ (Completely Fair Queuing, complete fair line)

Characteristics:

In the latest kernel version and release, CFQ is chosen as the default I/O scheduler, which is also the best choice for a common server.

CFQ attempts to evenly distribute access to I/O bandwidth, avoiding starvation of processes and achieving lower latencies, which is a tradeoff between the deadline and as schedulers.

CFQ is the best choice for multimedia applications (Video,audio) and desktop systems.

The CFQ gives the I/O request a priority, and the I/O priority requests are independent of the process priority, and the high-priority process reads and writes cannot automatically inherit high I/O priorities.

Working principle:

CFQ creates a separate queue for each process/thread to manage the requests generated by the process, i.e. one queue per process, scheduling between queues using time slices to ensure that each process is well allocated to the I/O bandwidth. The I/O Scheduler executes 4 requests per process at a time.

2) NOOP (Elevator-type dispatch program)

Characteristics:

In Linux2.4 or earlier versions of the scheduler, there was only one I/O scheduling algorithm at that time.

NoOp implements a FIFO queue that organizes I/O requests like the work of the elevator, and when a new request arrives, it merges the request into the most recent request to ensure that the same media is requested.

NoOp tends to starve to read while writing.

NoOp is the best choice for flash memory devices, RAM, and embedded systems.

The elevator algorithm starved read request explanation:

Because writing requests is easier than reading requests.

Write requests through the file system cache, do not have to wait a write completion, you can start the next write operation, write requests by merging, piled up into the I/O queue.

The read request needs to wait until all of the read operations in front of it have completed before the next read operation. There are a few milliseconds between reads, and the write request comes in between, starving the subsequent read request.

3) Deadline (Deadline scheduler)

Characteristics:

This classification and merging requirements are similar to the NOOP scheduler, which is categorized by time and hard drive area.

Deadline ensures that a service request is made within a cutoff time, which is adjustable and the default read period is shorter than the write period. This prevents the write operation from starving to death because it cannot be read.

Deadline is the best choice for the database environment (ORACLE rac,mysql, etc.).

4) as (expected I/O scheduler)

Characteristics:

Essentially the same as deadline, but after the last read operation, wait for 6ms to continue scheduling other I/O requests.

You can subscribe to a new read request from the application to improve the execution of the read operation, but at the expense of some write operations.

It inserts new I/O operations into each 6ms, while some small write streams are combined into an uppercase stream, with write latencies for maximum write throughput.

As is suitable for writing more environments, such as file servers

As has a poor performance on the database environment.

iii) View and setup of I/O scheduling methods

1) View the I/O schedule for the current system

[Root@test1 tmp]# Cat/sys/block/sda/queue/scheduler

NoOp anticipatory deadline [CFQ]

2) temporarily change I/O scheduling

For example: To change to noop elevator scheduling algorithm:

echo NoOp >/sys/block/sda/queue/scheduler

3) Permanently change I/O scheduling

Modify kernel boot parameters, add elevator= Scheduler name

[Root@test1 tmp]# Vi/boot/grub/menu.lst

Change to the following:

Kernel/boot/vmlinuz-2.6.18-8.el5 ro root=label=/elevator=deadline rhgb quiet

After rebooting, review the scheduling method:

[Root@test1 ~]# Cat/sys/block/sda/queue/scheduler

NoOp anticipatory [deadline] Cfq

It's already deadline.

IV) Ionice

Ionice can change the type and priority of a task, but only the CFQ scheduler can use Ionice.

There are three examples to illustrate the function of Ionice:

Real-time scheduling with CFQ with a priority of 7

Ionice-c1-n7-ptime DD if=/dev/sda1 f=/tmp/test bs=2m count=300&

Default disk I/O scheduling with a priority of 3

Ionice-c2-n3-ptime DD if=/dev/sda1 f=/tmp/test bs=2m count=300&

Takes a free disk schedule with a priority of 0

Ionice-c3-n0-ptime DD if=/dev/sda1 f=/tmp/test bs=2m count=300&

Ionice Three scheduling methods, the highest real-time scheduling, followed by the default I/O scheduling, and finally the idle disk scheduling.

Ionice has 8 priority disk scheduling, with a maximum of 0 and a minimum of 7.

Note that the priority of disk scheduling is not related to the priority of the process Nice.

One is the priority for process I/O and one for the CPU of the process.

IO scheduling algorithm

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.