Linux Performance Optimization 6: I/O scheduling algorithm selection

Source: Internet
Author: User
Linux performance tuning 6: selecting IO scheduling algorithms 5: optimizing soft raidhttp: // www.2cto.com/ OS /201307/228240.html1) summary of I/O scheduling program 1) when a data block is written to the device or read from the device, the request is placed in... linux Performance Optimization 6: I/O scheduling algorithm selection
Linux performance tuning 5: optimizing soft raid http://www.2cto.com/os/201307/228240.html I) I/O scheduler summary 1) requests are placed in a queue waiting for completion when data blocks are written to or read from the device. 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 effective use of media. the I/O scheduler converts unordered I/O operations into ordered I/O operations. 4) The Kernel must first determine the total number of requests in the queue before scheduling starts. ii) 4 Algorithms for I/O scheduling 1) CFQ (Completely Fair Queuing, fully Fair Queuing) features: In the latest kernel version and release version, CFQ is selected as the default I/O scheduler, which is also the best choice for general servers. CFQ tries to evenly distribute access to the I/O bandwidth to prevent the process from starvation and achieve low latency, which is a compromise between deadline and as scheduler. CFQ is the best choice for multimedia applications (video, audio) and desktop systems. CFQ assigns an I/O request priority, while an I/O request priority is independent of a process priority, Read/write of a high-priority process cannot automatically inherit the high I/O priority. working Principle: CFQ creates a separate queue for each process/thread to manage the requests generated by the process. that is to say, each process has a queue, and scheduling between queues uses time slices for scheduling, to ensure that each process can be well allocated to the I/O bandwidth. the I/O scheduler executes four requests for a process each time. 2) NOOP (elevator-type scheduling program) features: In the Linux2.4 or earlier version of the scheduling program, there was only this I/O scheduling algorithm. NOOP implements a FIFO queue, which organizes I/O requests like the elevator master method. when a new request arrives, it combines requests to the nearest request to ensure that the request is in the same media. NOOP tends to starve to read and facilitate writing. NOOP is the best choice for flash memory devices, RAM, and embedded systems. elevator algorithm starved read request explanation: Because write requests are easier than read requests. write requests are cached by the file system. you do not need to wait for one write to complete. you can start the next write operation. write requests are merged and stacked into the I/O queue.. The next read operation can be performed only after all the previous read operations are completed. there are several milliseconds between read operations, and write requests come between them, starving the subsequent read requests. 3) Deadline (Deadline scheduler) features: Classification by time and hard disk area. this classification and merger are required to be similar to noop scheduler. deadline ensures that the service request is made within the Deadline. The Deadline is adjustable, and the default read period is shorter than the write period. this prevents the write operation from getting starved to death because it cannot be read. deadline is the best choice for database environments (such as oracle rac and MYSQL. 4) AS (unexpected I/O scheduler) features: essentially the same AS Deadline, but wait 6 ms after the last read operation, to continue scheduling other I/O requests. you can reserve a new read request from the application to improve the execution of read operations, but at the cost of some write operations. it inserts a new I/O operation in each 6 ms, and merges some lower-case streams into one upper-case stream. In exchange for the maximum write throughput. AS is suitable for writing to a large number of environments. for example, the file server AS performs poorly on the database environment. 3) view and set the I/O scheduling method 1) view the I/O scheduling of the current system [root @ test1 tmp] # cat/sys/block/sda/queue/scheduler noop anticipatory deadline [cfq] 2) temporary change of I/O scheduling for example: to change to noop elevator scheduling algorithm: echo noop>/sys/block/sda/queue/scheduler 3) permanently change the I/O scheduling and modify the kernel boot parameters. add elevator = scheduler name [root @ test1 tmp] # vi/boot/grub/menu. lst changed to the following: kernel/boot/vmlinuz-2.6.18-8.el5 ro root = LABEL =/elevator = deadline r After hgb quiet is restarted, check the scheduling method: [root @ test1 ~] # Cat/sys/block/sda/queue/scheduler noop anticipatory [deadline] cfq is already deadline. 4) ionice can change the task type and priority, however, only the cfq scheduler can use ionice. there are three examples to illustrate the functions of ionice: using real-time cfq scheduling, priority: 7 ionice-c1-n7-ptime dd if =/dev/sda1 f =/tmp/test bs = 2 M count = 300 & use the default disk I/O scheduling, priority: 3 ionice-c2-n3-ptime dd if =/dev/sda1 f =/tmp/test bs = 2 M count = 300 & use idle disk scheduling, priority is 0 ionice-c3-n0-ptime dd if =/dev/sda1 f =/tmp/test bs = 2 M count = 300 & ionice three scheduling methods, real-time scheduling is the highest, followed by default I/O scheduling, and finally idle disk scheduling. there are eight Disk scheduling priorities for ionice, with a maximum of 0 and a minimum of 7. note that the disk scheduling priority has nothing to do with the nice process priority. one is the priority of process I/O, and the other is the priority of process CPU.
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.