I/O Scheduler
When your system has dozens of processes all reading and writing to disk at once, who goes first? That's the I/O scheduler's job — it decides the order of disk requests to maximize throughput, minimize latency, and be fair to all processes.
Why Does Order Matter?
HDD vs SSD — Different Needs
| HDD | NVMe SSD | |
|---|---|---|
| Seek time | 5–15ms (physical head movement) | ~0.1ms (no moving parts) |
| Random vs sequential | Sequential much faster | Comparable speed |
| Scheduling benefit | High — reorder saves seek time | Low — hardware handles it |
| Best scheduler | BFQ or mq-deadline | none (no scheduler) |
| Queue depth | 1 (single queue) | Up to 65535 (multi-queue) |
The Schedulers — Old and New
none / noop — No Scheduling
No reordering. Requests processed in arrival order (FIFO), with basic merging of adjacent requests. Best for NVMe SSDs where the device's own hardware queue is smarter than any software scheduler. Also used in VMs (the host handles scheduling).
mq-deadline — Deadline-Based
Each request gets a deadline (default: 500ms reads, 5s writes). The scheduler batches requests for throughput but guarantees no request waits past its deadline. Good balance for SSDs and HDDs. Prevents write starvation — a common problem when reads always jump the queue.
BFQ — Budget Fair Queuing
Assigns each process a "budget" of disk sectors. Processes get fair slices of disk bandwidth, similar to CPU scheduling. Great for desktop use: your music player won't stutter while a large file copies. Slightly higher CPU overhead than mq-deadline. Best for HDDs and SATA SSDs on interactive systems.
CFQ — Completely Fair Queuing (legacy)
The old default before multi-queue block layer. Replaced by BFQ. Uses per-process I/O queues with time slices. Still available but deprecated — use BFQ instead.
Check and Change Schedulers
Which Scheduler to Use?
| Workload | Device | Recommended | Why |
|---|---|---|---|
| NVMe SSD (any workload) | NVMe | none | Device handles queuing natively |
| Desktop / interactive | HDD/SATA SSD | BFQ | Fair per-process, no stutter |
| Database server | SATA SSD | mq-deadline | Lower latency, deadline guarantees |
| VM guest | Virtual disk | none | Host hypervisor handles it |
| Spinning HDD, latency matters | HDD | mq-deadline | Prevents starvation |
Tuning Queue Depth and Read-Ahead
Frequently Asked Questions
What will I learn here?
This page covers the core concepts and techniques you need to understand the topic and progress confidently to the next lesson.
How should I use this page?
Start with the overview, then follow the section links to deepen your understanding. Use the table of contents on the right to jump to specific sections.
What should I read next?
Use the navigation below to continue to the next lesson or explore related topics.