MySQL Server LinuxIO scheduler algorithm selection

Source: Internet
Author: User
Iosched 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.

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.

I. 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. Next we follow the simple to complex sequence. Below are several IO scheduling algorithms provided by the Linux 2.6 kernel.

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.

Ii. view and modify the algorithm of the I/O scheduler in Linux (take CentOS5.5 as an example ):


[Root @ dbserver2 ~] # Cat/etc/RedHat-release

CentOS release 5.5 (Final)

[Root @ dbserver2 ~] # Uname-

Linux dbserver2 2.6.18-194. el5 #1 SMP Fri Apr 2 14:58:14 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux

1. Check the method for setting the IO scheduling algorithm when the machine is 2.6 kernel:


[Root @ dbserver2 ~] # Fdisk-l

Disk/dev/sda: 598.8 GB, 598879502336 bytes

255 heads, 63 sectors/track, 72809 cylinders

Units = cylinders of 16065*512 = 8225280 bytes

Device Boot Start End Blocks Id System

/Dev/sda1*1 13 104391 83 Linux

/Dev/sda2 14 65669 527381820 83 Linux

/Dev/sda3 65670 68219 20482875 83 Linux

/Dev/sda4 68220 72809 36869175 5 Extended

/Dev/sda5 68220 70769 20482843 + 83 Linux

/Dev/sda6 70770 72809 16386268 + 82 Linux swap/Solaris

[Root @ dbserver2 ~] #

[Root @ dbserver2 ~] # Find/-iname "scheduler"

/Sys/block/sr0/queue/schedue

/Sys/block/sda/queue/schedue

View the current IO Scheduling Algorithm of the system


[Root @ dbserver2 ~] # Cat/sys/block/sda/queue/schedue

Noop anticipatory deadline [cfq] ---- the currently used algorithm in parentheses

2. Modify the IO scheduling algorithm:


[Root @ test80 ~] # Echo deadline>/sys/block/sda/queue/scheduler

[Root @ test80 ~] # Cat/sys/block/sda/queue/schedue

Noop anticipatory [deadline] cfq can be seen that the IO scheduling algorithm has been modified to deadline

Iii. Optimization settings for the IO Scheduling Algorithm of the MYSQL database server:

1. CFQ is used in scenarios with uniform IO sizes.

2. The DeadLine algorithm is recommended for complex OLTP environments.

3. Noop algorithm can be used when IO performance is not a bottleneck

4. Anticipatory is not suitable for database environments. This algorithm is not recommended for DB servers.

5. the simplest NOOP of emerging solid state disks, such as SSD and Fusion IO, 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.

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.