Operations 8 min read

Mastering Linux I/O Schedulers: CFQ, NOOP, Deadline, and AS Explained

This article provides a comprehensive overview of Linux I/O schedulers, detailing the purpose of I/O scheduling, describing the four main algorithms (CFQ, NOOP, Deadline, AS), and offering practical commands for viewing, temporarily changing, permanently setting the scheduler, as well as using ionice for priority control.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
Mastering Linux I/O Schedulers: CFQ, NOOP, Deadline, and AS Explained

I. Summary of I/O Scheduler

When writing or reading data blocks to/from a device, requests are placed in a queue awaiting completion.

Each block device has its own queue.

The I/O scheduler maintains the order of these queues to use the medium more efficiently, turning unordered I/O operations into ordered ones.

The kernel must first determine the total number of requests in the queue before scheduling.

II. Four I/O Scheduling Algorithms

1) CFQ (Completely Fair Queuing)

Features: CFQ is the default I/O scheduler in recent kernels and distributions, suitable for general servers, multimedia applications, and desktop systems. It distributes I/O bandwidth evenly, avoids starvation, and provides low latency, balancing between deadline and AS schedulers. CFQ assigns each I/O request a priority independent of process priority.

How it works: CFQ creates a separate queue for each process/thread, scheduling these queues using time slices, ensuring each process receives fair I/O bandwidth. The scheduler executes four requests from a process at a time.

2) NOOP (Elevator Scheduler)

Features: Implemented as a simple FIFO queue, it merges new requests with the nearest existing one, suitable for flash devices, RAM, and embedded systems. It tends to starve read requests in favor of writes.

3) Deadline

Features: Classifies requests by time and disk region, similar to NOOP. It guarantees service within a configurable deadline, with a shorter read deadline than write, preventing write starvation. Ideal for database environments (Oracle RAC, MySQL, etc.).

4) AS (Anticipatory Scheduler)

Features: Similar to Deadline but inserts a 6 ms pause after the last read before scheduling other I/O, improving read performance at the cost of some write throughput. Suitable for write‑heavy workloads like file servers, but performs poorly for databases.

III. Viewing and Setting the I/O Scheduler

View current scheduler:

cat /sys/block/sda/queue/scheduler
noop anticipatory deadline [cfq]

Temporarily change scheduler (e.g., to NOOP):

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

Permanently change scheduler by adding elevator= to kernel boot parameters (e.g., deadline):

vim /boot/grub/menu.lst
# add: kernel /boot/vmlinuz-... ro root=LABEL=/ elevator=deadline rhgb quiet

After reboot, verify:

cat /sys/block/sda/queue/scheduler
noop anticipatory [deadline] cfq

IV. ionice

ionice adjusts the I/O priority of tasks, but works only with the CFQ scheduler. Examples:

ionice -c1 -n7 -p time dd if=/dev/sda1 of=/tmp/test bs=2M count=300 &
ionice -c2 -n3 -p time dd if=/dev/sda1 of=/tmp/test bs=2M count=300 &
ionice -c3 -n0 -p time dd if=/dev/sda1 of=/tmp/test bs=2M count=300 &

ionice provides three classes: real‑time (highest), best‑effort (default), and idle (lowest). Priorities range from 0 (highest) to 7 (lowest) and are independent of CPU nice values.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

LinuxI/O schedulerDeadlineCFQNOOPionice
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.