Comparing Linux Block Schedulers (none, kyber, mq-deadline) on Flash Drives

Comparing Linux Block Schedulers (none, kyber, mq-deadline) on Flash Drives
Verified Answer

Set the Linux blk-mq scheduler to none on enterprise NVMe and hardware-RAID SSDs because their deep multi-queue controllers handle dispatch ordering without host CPU lock contention. For single-queue SATA or SAS 12G SSDs experiencing mixed read/write stalls, select mq-deadline or kyber to protect synchronous read latency.

Quick Answer: Choosing the Optimal Linux Block Scheduler for Flash

On enterprise NVMe and hardware-RAID flash arrays with deep internal queues, set the Linux blk-mq scheduler to none to bypass redundant software sorting and eliminate CPU lock contention. On single-queue SATA or SAS 12G SSDs experiencing mixed read/write contention, use mq-deadline (for strict write-starvation protection) or kyber (for token-based p99 read latency targets).

Core Stack & Parameters: sysfs /sys/block/*/queue/scheduler, blk-mq, none, kyber, mq-deadline, udev rules, fio latency verification

Linux block I/O schedulers originally built to sort spinning disk seeks add unnecessary CPU lock contention on solid-state storage. Leaving default queuing policies active on multi-queue NVMe or hardware RAID volumes inflates tail latency under load. Here we compare none, kyber, and mq-deadline schedulers, udev persistence, and fio checks.

Redundant Software Elevator Sorting

Sorting block requests in software wastes CPU cycles on flash controllers that already schedule parallel NAND channels.

Workload Queue Contention

While NVMe arrays thrive on none, mixed-load SATA/SAS drives still need kyber or mq-deadline to prevent starvation.

Persistent udev Scheduler Rules

Inspect sysfs queue schedulers, deploy persistent udev rules per bus type, and validate p99 latency with fio.

1. Why Legacy Elevator Sorting Hurts Modern Flash Queues

Traditional Linux disk elevators such as CFQ and single-queue deadline were engineered for spinning magnetic platters where physical seek distance dominated access time. Every microsecond spent merging adjacent sectors and sorting LBA offsets in kernel RAM saved milliseconds of mechanical head movement. On enterprise solid-state drives, random 4K reads and sequential reads resolve in tens of microseconds with zero mechanical seek penalty, which flips the cost equation completely.

When a high-IOPS flash drive sits behind an unnecessary software elevator, the kernel acquires queue locks, allocates request tags, and sorts bio structures that the SSD’s own Flash Translation Layer (FTL) will immediately scatter across parallel NAND channels anyway. On multi-socket servers running linux io scheduler kyber ssd workloads at 300,000+ IOPS, software scheduler lock contention can consume multiple CPU cores and inflate tail latency by 15% to 40%.

However, blindly setting every block device to none is equally risky on mixed-use SATA or SAS arrays. When a background backup, compaction job, or bulk rsync floods a 32-slot SATA NCQ queue with large 1MB writes, synchronous 4K database reads get stuck behind hundreds of megabytes of queued writes. On SSD Dedicated Server Hosting, matching the exact blk-mq scheduler to your drive interface and workload profile eliminates both wasted CPU overhead and read-starvation stalls.

1.1 How blk-mq Maps Software Staging Queues to Hardware Dispatch Rings

Modern Linux kernels (5.x and 6.x) route all block I/O through the multi-queue framework (blk-mq), which maintains per-CPU software staging queues mapped to hardware dispatch queues. With none, requests pass straight from the software staging queue to the NVMe or HBA driver ring with minimal locking, preserving strict NUMA locality when hardware MSI-X interrupts are bound to the same CPU socket. With kyber or mq-deadline, an extra scheduling stage intercepts requests to enforce latency budgets or expiration deadlines before hardware dispatch, trading modest CPU cycles for deterministic read prioritization under heavy writeback.

1.2 Why SATA NCQ=32 Needs Read-Priority Protection

While PCIe NVMe SSDs expose up to 64K queues with 64K entries each, direct-attached SATA 6Gbps SSDs are limited by the AHCI specification to a single 32-entry Native Command Queue (NCQ). Without mq-deadline or kyber throttling heavy sequential writes at the OS layer, bulk writeback can monopolize all 32 NCQ slots and push synchronous database 4K reads past 25ms. By contrast, SAS 12G/24G enterprise SSDs support deeper Tagged Command Queuing (TCQ) depths—typically 128 to 256 commands—making kyber an ideal middle ground when mixed OLTP reads compete with background compaction.

1.3 Understanding Kyber’s Two-Domain Token Bucket Model

Unlike mq-deadline, which sorts requests into red-black trees by LBA and enforces hard millisecond expiration timers (read_expire=500ms, write_expire=5000ms), kyber was built specifically for fast flash devices with zero seek penalty. It divides I/O into read and synchronous/asynchronous write domains, dynamically scaling the number of in-flight dispatch tokens whenever p99 completion latency exceeds read_lat_nsec (default 2ms) or write_lat_nsec (default 10ms). This prevents background dirty-page flushing from flooding the drive without incurring LBA tree-sorting overhead.

2. Linux blk-mq Scheduler Comparison Matrix

Choosing between none, kyber, and mq-deadline depends on where your flash controller’s bottlenecks actually live. A hardware RAID controller with 4GB of NV-backed write-back cache or a PCIe Gen4 U.3 SSD with 64K hardware queues performs its own internal LBA reordering far faster than the Linux kernel can.

Conversely, a direct-attached SATA 6Gbps SSD behind an AHCI or IT-mode HBA has a shallow NCQ depth of 32 commands. Under heavy sequential logging or backup streams, unthrottled writes can saturate those 32 slots unless a scheduler enforces read/write fairness.

Scheduler Queue Mechanism CPU & Lock Overhead Best Enterprise Flash Use Case
none FIFO pass-through directly to driver Lowest (near-zero kernel sorting) Hardware RAID w/ CacheVault, U.2/U.3 NVMe, Ceph OSDs
kyber Token-bucket read/write latency targets Low-Moderate (per-domain tokens) High-speed SAS/NVMe with mixed OLTP reads + async writes
mq-deadline Sorted FIFO with read/write expiration Moderate (single-queue lock on dispatch) Direct SATA SSDs (NCQ=32) under heavy write/compaction bursts
bfq Proportional bandwidth fairness Highest (heavy per-cgroup accounting) Desktop/interactive hosts; avoid on high-IOPS servers

Benchmarking with fio at queue depths matching your real workload (typically QD=1 to QD=32 for OLTP databases, QD=64+ for parallel analytics) confirms whether software scheduling helps or adds unnecessary CPU cycles. Always measure 99th and 99.9th percentile completion latency (clat) alongside CPU system time (%sys), because two schedulers can deliver identical average throughput while differing by an order of magnitude in tail latency under concurrent write bursts.

2.1 Why Virtualized Guest Kernels and Bare-Metal Hosts Use Different Defaults

On bare-metal Linux servers, the kernel sees the true physical transport—whether an NVMe namespace, a direct AHCI SATA port, or a MegaRAID logical volume. In virtualized environments, a guest VM’s virtio-blk or virtio-scsi device often defaults to none or mq-deadline depending on the distribution. When running KVM hypervisors on bare-metal flash, set the host physical NVMe drives to none and let the host handle queue fairness (or use io_uring) rather than stacking two independent software schedulers inside both the guest and host kernels.

2.2 Interactions Between I/O Schedulers, Cgroups v2 io.latency, and ZFS

If your infrastructure uses systemd slices or Kubernetes pods with cgroups v2 I/O throttling (io.max or io.latency), note that blk-mq enforces cgroup I/O control at the block QoS layer independently of none, kyber, or mq-deadline. Meanwhile, OpenZFS bypasses much of the standard Linux elevator behavior by issuing its own prioritized zio queues—meaning setting underlying ZFS pool member devices to none prevents double-sorting and reduces CPU overhead during scrubs and resilvers.

3. Auditing and Persisting Block Schedulers via sysfs and udev

Linux exposes active and available block schedulers per device through /sys/block/<dev>/queue/scheduler. Changes written directly to sysfs take effect immediately without unmounting filesystems, making live A/B latency testing safe on staging or drained replicas.

Because sysfs values reset on reboot or hot-plug events, production servers must persist scheduler policies using deterministic udev rules keyed by transport type (nvme, ata, or sas) or rotational flag.

3.1 Inspect Active Schedulers and Queue Depths Across All Flash Drives

Query sysfs to see which scheduler is bracketed as active, the hardware queue count, and whether the kernel recognizes each drive as non-rotational:

Terminal / Bash

for dev in /sys/block/sd* /sys/block/nvme*; do
  [ -e "$dev" ] || continue
  name=$(basename "$dev")
  sched=$(cat "$dev/queue/scheduler" 2>/dev/null)
  nr=$(cat "$dev/queue/nr_requests" 2>/dev/null)
  rot=$(cat "$dev/queue/rotational" 2>/dev/null)
  echo "$name | rotational=$rot | nr_requests=$nr | scheduler=$sched"
done

If rotational=1 appears on a virtualized or RAID-backed SSD volume, immediately verify controller passthrough or force rotational=0 so the kernel disables random-entropy harvesting and rotational seek heuristics.

3.2 Tune Kyber Latency Targets and Persist via udev Rules

When running mixed database reads and WAL writes on SAS 12G or NVMe flash, test Kyber with explicit read/write nanosecond budgets, then lock the policy in /etc/udev/rules.d/60-ssd-scheduler.rules:

Terminal / Bash

# Live test kyber on /dev/sdb with 2ms read / 10ms write targets
echo kyber | sudo tee /sys/block/sdb/queue/scheduler
echo 2000000 | sudo tee /sys/block/sdb/queue/iosched/read_lat_nsec
echo 10000000 | sudo tee /sys/block/sdb/queue/iosched/write_lat_nsec

# Persist across reboots: /etc/udev/rules.d/60-ssd-scheduler.rules
ACTION=="add|change", KERNEL=="nvme[0-9]*n[0-9]*", ATTR{queue/scheduler}="none"
ACTION=="add|change", KERNEL=="sd[a-z]*", ATTR{queue/rotational}=="0", ATTR{queue/scheduler}="mq-deadline"

Reload udev with sudo udevadm control --reload-rules && sudo udevadm trigger --subsystem-match=block and re-run the inspection loop to confirm persistence without rebooting.

3.3 Validate p99 Tail Latency Under Mixed Read/Write Load with fio

Never trust average latency alone. Run a non-destructive read-heavy mixed benchmark on a test file to compare p99 completion latency between schedulers:

Terminal / Bash

sudo fio --name=sched-test --filename=/mnt/ssd-test/fio.dat --size=4G \
  --ioengine=io_uring --direct=1 --rw=randrw --rwmixread=70 --bs=4k \
  --iodepth=32 --numjobs=4 --time_based --runtime=30 --group_reporting

Compare the clat percentiles (usec): 99.00th line across none, kyber, and mq-deadline. Choose the scheduler with the tightest p99 latency at your target IOPS.

3.4 Tuning mq-deadline Expiration Timers for Heavy Database Writeback

On direct-attached SATA SSDs running PostgreSQL checkpoints or MySQL InnoDB buffer-pool flushes, default mq-deadline timers (500ms read, 5000ms write) are tuned for spinning disks. Tightening read_expire and writes_starved via sysfs forces the scheduler to prioritize synchronous reads far more aggressively:

Terminal / Bash

# Tighten mq-deadline for flash responsiveness on /dev/sdb
echo mq-deadline | sudo tee /sys/block/sdb/queue/scheduler
echo 50 | sudo tee /sys/block/sdb/queue/iosched/read_expire
echo 500 | sudo tee /sys/block/sdb/queue/iosched/write_expire
echo 1 | sudo tee /sys/block/sdb/queue/iosched/fifo_batch

Setting fifo_batch=1 ensures the kernel dispatches small batches rather than draining 16 consecutive sequential writes ahead of a waiting database read.

4. Production I/O Scheduler Deployment Standards

Standardize these four kernel block-layer practices across bare-metal flash deployments to keep p99 latency predictable under peak concurrency:

1. Bypass Sorting on Hardware RAID

Always set scheduler=none on MegaRAID or Smart Array logical volumes so the Linux kernel does not double-sort behind CacheVault.

2. Protect Shallow SATA Queues

Use mq-deadline on direct-attached SATA SSDs to prevent bulk writes from starving synchronous 4K database reads.

3. Disable I/O Stats if Bottlenecked

At >500K IOPS, setting queue/iostats=0 removes per-I/O timestamp accounting overhead when external telemetry isn’t needed.

4. Match nr_requests to Workload

Lower nr_requests from 256 to 64 on latency-sensitive OLTP nodes to prevent deep kernel bufferbloat during write bursts.

5. Troubleshooting Latency Spikes and Safe Rollback

If switching to kyber or lowering read_lat_nsec causes unexpected throughput drops during batch ETL jobs or ZFS scrubs, the token bucket may be throttling background writes too aggressively. Symptoms include rising %iowait in vmstat while drive utilization sits below 60%.

Because scheduler changes in sysfs are atomic and non-destructive, you can revert to mq-deadline or none live without interrupting active database connections or unmounting volumes:

Terminal / Bash

# Immediate live rollback to mq-deadline on /dev/sdb
echo mq-deadline | sudo tee /sys/block/sdb/queue/scheduler
# Verify no stuck requests in blk-mq debugfs
sudo grep -H . /sys/block/sdb/mq/*/cpu_list 2>/dev/null | head -n 5

If a custom udev rule caused boot-time warnings, remove the rule file from /etc/udev/rules.d/60-ssd-scheduler.rules and regenerate initramfs if your distribution embeds storage udev rules early in boot.

Related SSD Dedicated Server Engineering Guides

Review our primary SSD Dedicated Server Hosting architecture hub, alongside Scaling Linux blk-mq Hardware Queues Across NUMA Cores and Lowering Async Disk Syscall Overhead with Kernel io_uring Instead of libaio.

Frequently Asked Questions

Should I use none or kyber on PCIe NVMe and U.3 SSDs?

Start with none on modern NVMe and U.3 drives because they expose thousands of hardware queues directly to blk-mq. Only switch to kyber if mixed heavy writes measurably degrade p99 read latency.

Why does /sys/block/nvme0n1/queue/scheduler only show [none] on some kernels?

Some cloud or custom kernels omit loadable scheduler modules or compile blk-mq with none as default until mq-deadline or kyber modules are loaded via modprobe.

Does changing the I/O scheduler affect ZFS pools?

ZFS has its own internal I/O scheduler (zio) that prioritizes sync writes and reads. Setting the underlying Linux block device scheduler to none avoids double-scheduling overhead.

Can I change the Linux I/O scheduler on a live production database server?

Yes. Echoing a new scheduler name into /sys/block/<dev>/queue/scheduler is atomic and safe on mounted filesystems, though you should test during low-traffic windows first.

Does the Linux kernel I/O scheduler affect mdadm software RAID arrays?

Virtual md0 devices report scheduler=none because mdadm dispatches I/O directly to underlying physical member disks. Always tune the scheduler (none for NVMe, mq-deadline for SATA) on the underlying physical member devices such as /dev/sda or /dev/nvme0n1.

Deploy Bare-Metal Flash with Full Kernel Scheduler Control

Tuning blk-mq to none or kyber removes host CPU lock contention only when you control the underlying physical block queues. Review dedicated SATA, SAS 12G, and U.2/U.3 SSD servers with root kernel access.

Compare SSD Dedicated Servers