Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to modify disk scheduling algorithm in linux

2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

How to modify the disk scheduling algorithm in linux, in view of this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.

The overall goal of the IO scheduler is to make the head always move in one direction, to the end, and then in the opposite direction, which is precisely the elevator model in real life, so the IO scheduler is also called an elevator. (elevator) and the corresponding algorithm is also called the elevator algorithm. There are several elevator algorithms for IO scheduling in Linux, one is called as (Anticipatory), one is called cfq (Complete Fairness Queueing), one is called deadline, and the other is called noop (No Operation). We can specify which algorithm to use at startup through the kernel parameter elevator.

1) four algorithms for Ipaw O scheduling

1) CFQ (fully fair queuing IAccord O scheduler)

Features:

In the latest kernel versions and distributions, CFQ is chosen as the default Imax O scheduler, which is also the best choice for general-purpose servers.

CFQ attempts to evenly distribute the access to the bandwidth of deadline O to avoid starvation and achieve lower latency, which is a compromise between deadline and as schedulers.

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

CFQ assigns a priority to the Icano request, which is independent of the process priority, and the read and write of the high priority process can not automatically inherit the high Icano priority.

How it works:

CFQ creates a separate queue for each process / thread to manage requests generated by that process, that is, each process has a queue, and scheduling between queues is scheduled using time slices.

This ensures that each process can be well allocated to the I / O bandwidth I / O scheduler to execute four requests for one process at a time.

2) NOOP (elevator dispatcher)

Features:

In Linux2.4 or earlier versions of the scheduler, there was only one Imax O scheduling algorithm.

NOOP implements a simple FIFO queue, which organizes Imax O requests like the elevator master method. When a new request arrives, it merges the request after the most recent request to ensure that the request is the same medium.

NOOP tends to starve to death and is good for writing.

NOOP is the best choice for flash devices, RAM, embedded systems.

Explanation of Elevator algorithm starvation request:

Because it is easier to write a request than to read it.

Write requests go through the file system cache, and do not need to wait for a write to complete before starting the next write operation. Write requests are merged and piled into the Imando O queue.

The read request needs to wait until all previous reads are completed before it can proceed to the next read. There are milliseconds between read operations, and write requests come in between, starving the rest of the read requests.

3) Deadline (deadline scheduler)

Features:

Sorting by time and hard disk area, this classification and merge requires a scheduler similar to noop.

Deadline ensures that requests are served within a deadline, which is adjustable, while the default read period is shorter than the write deadline. This prevents write operations from starving to death because they cannot be read.

Deadline is the best choice for database environments (ORACLE RAC,MYSQL, etc.).

4) AS (expected Iram O scheduler)

Features:

It is essentially the same as Deadline, but after the last read operation, you have to wait for 6ms before you can continue to schedule other IDeadline requests.

A new read request can be booked from the application to improve the execution of read operations, but at the expense of some writes.

It inserts a new Icano operation in each 6ms and merges some small write streams into one large write stream, trading write latency for maximum write throughput.

AS is suitable for environments with more writes, such as file servers

AS performs poorly in the database environment.

View the IO scheduling algorithms supported by the current system

Dmesg | grep-I scheduler

[root@localhost ~] # dmesg | grep-I scheduler

Io scheduler noop registered

Io scheduler anticipatory registered

Io scheduler deadline registered

Io scheduler cfq registered (default)

View the Istroke O scheduling method of the current system:

Cat / sys/block/sda/queue/scheduler

Noop anticipatory deadline [cfq]

Change the Imax O scheduling method on the spot:

For example: want to change to noop elevator scheduling algorithm:

Echo noop > / sys/block/sda/queue/scheduler

Want to permanently change the Iswap O scheduling method:

Modify the kernel boot parameters to add the name of the elevator= scheduler

CentOS7:

[root@localhost] # grubby-- update-kernel=ALL-- args= "elevator=deadline"

[root@localhost ~] # reboot

[root@localhost ~] # cat / sys/block/sda/queue/scheduler

Noop [deadline] cfq

CentOS6:

# vim / boot/grub/menu.lst

Change to the following: # # add elevator=deadline before rhgb quiet

Kernel / boot/vmlinuz-2 . six. 32-504.el6 ro root=LABEL=/ elevator=deadline rhgb quiet

After restarting, check the scheduling method:

Cat / sys/block/sda/queue/scheduler

Noop anticipatory [deadline] cfq

It's already deadline.

This is the answer to the question about how to modify the disk scheduling algorithm in linux. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel to learn more about it.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report