Scheduler Config
Linux provides several I/O schedulers to manage disk request ordering, and selecting the right one is critical for optimizing performance on HDDs and SSDs. This section explains how to configure and tune I/O schedulers using sysfs and kernel parameters, with guidance for different storage types.
Selecting the I/O Scheduler¶
The I/O scheduler for a block device can be dynamically changed at runtime or set at boot via kernel parameters. To check the current scheduler:
Replace <device> with the block device name (e.g., sda, nvme0n1). The output lists available schedulers, such as deadline, cfq, noop, and none.
Recommended Schedulers¶
- HDDs: Use
deadlinefor sequential workloads orcfqfor fairness.deadlineis generally preferred for rotational media. - SSDs: Use
noopfor most cases, as SSDs have low seek times and benefit from minimal scheduling overhead.deadlinecan be used for specific workloads like databases. - NVMe SSDs:
noopis typically optimal, butdeadlinemay offer better performance in some scenarios.
To switch the scheduler for a device:
Note: Changes take effect immediately but may require a reboot for persistent settings.
Tuning via sysfs¶
Many schedulers expose tunable parameters through sysfs. For example:
Deadline Scheduler¶
io_schedule_max: Maximum number of I/O requests to schedule (default: 256).deadline: Enables deadline scheduling (default:1).
Example:
NOOP Scheduler¶
nr_requests: Maximum number of I/O requests to queue (default: 128). Increase for high-throughput workloads:
CFQ Scheduler¶
cfq_slice_time: Time slice for I/O requests (default: 100ms). Reduce for low-latency needs:
Kernel Parameters¶
Set the default scheduler at boot by modifying kernel command-line parameters:
-
Edit
Replace/etc/default/grub:<scheduler>withdeadline,noop, orcfq. -
Update GRUB:
Note: Kernel parameters apply to all block devices. Use blkdev or sysfs for device-specific tuning.
Best Practices for HDD/SSD¶
- HDDs: Prioritize
deadlinefor sequential workloads. Avoidnoopunless testing shows performance gains. - SSDs: Use
noopas the default. For NVMe SSDs,deadlinemay offer better performance in some cases. - Monitoring: Use tools like
iostat,iotop, ordstatto measure I/O performance after changes. - Persistent Configuration: Always test changes in a non-production environment before applying them system-wide.
Key takeaways¶
- Use
deadlinefor HDDs andnoopfor SSDs to match storage characteristics. - Tune sysfs parameters like
nr_requestsorio_schedule_maxfor workload-specific needs. - Kernel parameters set the default scheduler, but device-specific sysfs tuning offers finer control.
- Always validate performance changes with monitoring tools before deploying in production.