In this lesson, you will learn how to select the optimal I/O scheduler to match your hardware's physical characteristics, maximizing throughput while minimizing latency.
The Problem of I/O Scheduling
The kernel's I/O scheduler acts as a gatekeeper between the file system and the storage hardware. Its primary job is to decide the order in which pending read and write requests are submitted to the storage device. While a simple "First-In, First-Out" approach seems fair, it is catastrophically inefficient for traditional spinning disks, which suffer from massive mechanical latency when the read/write head moves across platters.
Spinning Disks: Anticipatory and Deadline
For spinning disks (HDDs), we need to minimize "seek time." Schedulers like mq-deadline work by reordering requests to group them by their physical location on the disk. By sorting requests by their block number, the scheduler keeps the disk head movement linear rather than erratic. Furthermore, mq-deadline enforces a time limit on requests to prevent "starvation," where a specific process waits indefinitely because other requests are being prioritized.
Solid-State Storage: The Case for none or kyber
Solid-state storage (NVMe/SSD) operates fundamentally differently; there is no mechanical head and no penalty for non-sequential access. In fact, modern high-speed NVMe drives are so fast that the overhead of the kernel's complex sorting logic often becomes a bottleneck itself.
For high-performance NVMe devices, the optimal choice is frequently none. By bypassing the I/O scheduler entirely, you allow the kernel to pass requests directly to the hardware queue, letting the device’s internal controller handle the parallelism.
If you have a mixed-workload environment (e.g., a server with background writes competing with real-time user reads), kyber is an excellent choice. It monitors request latency and throttles specific queues to ensure critical requests meet their deadlines without the heavy computational overhead of older algorithms.
To inspect or change your scheduler for a device (e.g., /dev/nvme0n1), you can check the current policy:
cat /sys/block/nvme0n1/queue/scheduler
# To switch to none:
echo none | sudo tee /sys/block/nvme0n1/queue/scheduler
Key Takeaway: Use mq-deadline for mechanical spinning disks to minimize seek times, but prefer none for modern NVMe storage to reduce kernel overhead and exploit massive internal device parallelism.