Linux Kernel's 4 IO Schedulers Explained: Noop, CFQ, Deadline, Anticipatory
This article explains Linux kernel's four IO schedulers—Noop, CFQ, Deadline, and Anticipatory—detailing their mechanisms, priority handling, queue structures, and optimal use cases for traditional disks versus SSDs, covering request merging, sorting, fairness, deadline guarantees, and anticipatory waiting windows.
Reading font

Scheduling Algorithm Concepts
When data blocks are written to or read from a device, requests are placed in a queue waiting for completion. Each block device has its own queue. The I/O scheduler maintains the order of these queues to utilize the media more effectively, turning unordered I/O operations into ordered ones. The kernel must first determine how many requests are in the queue before scheduling begins.
IO Scheduler (IO Scheduler)
The IO scheduler decides the submission order of I/O operations on block devices. Its two goals are to increase I/O throughput and reduce I/O response time. These goals often conflict, so multiple scheduling algorithms are provided to suit different I/O request scenarios. For database workloads with random reads and writes, the Deadline algorithm is most advantageous.
In the kernel stack, the block device is the lowest layer. Disk rotation is the main performance bottleneck. Each block device or partition has its own request queue ( request_queue), and each queue can select an I/O scheduler to coordinate submitted requests. The scheduler's basic purpose is to sort requests by their sector numbers on the block device, reducing head movement and improving efficiency. Requests in the queue are serviced in order. Besides the main queue, each scheduler maintains its own internal queues to process incoming requests; the request at the front of the internal queue is moved to the device's request queue at the appropriate time.
The IO scheduler reduces the need for disk rotation mainly through two mechanisms:
Merging : When a new request arrives, if it is adjacent to an existing request in the queue, they are merged into a single request.
Sorting : If merging is not possible, requests are sorted according to the disk's rotation direction. The scheduler balances merging and sorting while trying not to excessively delay individual requests.
1. NOOP
NOOP (No Operation) is a simple FIFO scheduler: requests are processed as they arrive. It does nothing to reorder requests, which keeps the implementation simple and effective. However, it causes many disk seeks on traditional rotating disks, which is unacceptable. For SSDs, which have no moving parts, NOOP is suitable.
NOOP is also known as the elevator scheduling algorithm . Its principle:
Place I/O requests into a FIFO queue and execute them in order.
When a new request arrives:
If it can be merged with an existing request, merge it.
If it cannot be merged, attempt to insert it into the sorted position. If the requests already in the queue are very old, the new request cannot cut in line and is placed at the end. Otherwise, it is inserted at the appropriate sorted position.
If it cannot be merged and no suitable insertion point exists, place it at the end of the request queue.
Applicable scenarios:
Scenarios where the order of I/O requests must not be changed.
Devices with more intelligent scheduling algorithms underneath, such as NAS storage.
Upper-layer applications that have already carefully optimized their I/O requests.
Non-rotating magnetic head devices, such as SSDs.
2. CFQ (Completely Fair Queuing)
CFQ attempts to allocate a request queue and a time slice to every process competing for the block device. Within its allocated time slice, a process can submit its read/write requests to the underlying block device. When the time slice expires, the process's request queue is suspended until the scheduler grants it another turn.
Each process's time slice and queue length depend on its I/O priority. Every process has an I/O priority, which CFQ considers when determining when a process's queue gets device access. I/O priorities from high to low are:
RT (real time)
BE (best effort)
IDLE (idle)
RT and BE each have 8 sub-priorities, configurable via ionice. Higher priority means earlier processing, larger time slices, and more requests processed per turn.
CFQ's fairness applies to processes. Only synchronous requests (read or sync write) are associated with a process and placed in that process's private queue. All asynchronous requests of the same priority, regardless of originating process, are placed in shared queues. There are 8 (RT) + 8 (BE) + 1 (IDLE) = 17 asynchronous queues in total.
Since Linux 2.6.18, CFQ has been the default I/O scheduler. For general-purpose servers, CFQ is a good choice. However, the final selection should be based on thorough benchmarking for the specific workload, not solely on others' recommendations.
3. DEADLINE
DEADLINE builds on CFQ to solve the extreme case of I/O request starvation. In addition to CFQ's sorted queue, DEADLINE provides separate FIFO queues for read I/O and write I/O.
Read FIFO queue maximum wait time: 500 ms.
Write FIFO queue maximum wait time: 5 s (these parameters are tunable).
Priority order: FIFO(Read) > FIFO(Write) > CFQ .
The Deadline algorithm guarantees minimal latency for a given I/O request, making it well-suited for DSS (Decision Support System) applications.
Deadline improves on the Elevator algorithm in two ways:
Avoids requests waiting indefinitely.
Differentiates between read and write operations.
Deadline maintains three queues:
Queue 1: Sorted by physical position (like Elevator).
Queue 2: Read requests, sorted by submission time (FIFO).
Queue 3: Write requests, sorted by submission time (FIFO).
Reads are given higher priority because applications typically block waiting for read results, whereas writes often return after data reaches memory, with background flushing to disk later.
Each new request is placed into Queue 1 (sorted) and also appended to the appropriate read/write FIFO queue. The scheduler services requests from Queue 1 while checking the heads of the read/write FIFO queues; if a request has waited longer than its threshold (5 ms for reads, 5 s for writes per the article's later statement, though earlier it states 500 ms and 5 s), it is serviced immediately.
Author's note: For partitions storing database change logs (e.g., Oracle online logs, MySQL binlog), Deadline may not be ideal because these writes often use fsync; if writes don't complete quickly, application performance suffers.
4. ANTICIPATORY
CFQ and Deadline focus on satisfying random I/O requests. For sequential I/O (e.g., sequential reads), they lack optimization. To handle mixed random and sequential I/O, Linux supports the Anticipatory scheduler. Based on Deadline, Anticipatory adds a 6 ms waiting window for each read I/O. If the OS receives a read request for an adjacent sector within that 6 ms window, it can be serviced immediately, improving sequential read throughput.
Summary
The choice of I/O scheduler depends on both hardware characteristics and application scenarios.
On traditional SAS disks, CFQ, Deadline, and Anticipatory are all good choices; for dedicated database servers, Deadline offers strong throughput and response time.
On emerging solid-state drives (SSDs, Fusion-io), the simplest NOOP scheduler may be the best because the other three algorithms optimize for reducing seek time, which does not exist on SSDs, and SSDs have very short I/O response times.
For questions about attribution, corrections or content rights, please contactand we will review it promptly.