Can the Linux disk scheduler be changed on the fly by writing to /sys/block/sda/queue/scheduler
? Should applications (e.g. Mysql) be stopped / started when changing?
3 Answers
You can change the IO scheduler on the fly without fear. It is protected by appropriate locking to make sure no transactions are lost.
Yes you can, and no, applications do not need to be stopped/started. This is by design, so that you can (relatively) safely try out different ones on a production system without downtime.
It does cause a "hiccup"; IOs in progress are allowed to complete, and new IO requests are blocked until the new scheduler is instated.
You can also have a different IO scheduler per block device (as seen by the kernel e.g. /dev/sda).
You could add an
echo deadline > /sys/block/sda/queue/scheduler
(as example) at the start of application and anotherecho
at the end with the initial scheduler ..echo cfq > /sys/block/sda/queue/scheduler
You can make a
cron
script that verifies the application start and change the scheduler accordingly.