4

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 3

3

You can change the IO scheduler on the fly without fear. It is protected by appropriate locking to make sure no transactions are lost.

2

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).

1
  1. You could add an echo deadline > /sys/block/sda/queue/scheduler (as example) at the start of application and another echo at the end with the initial scheduler .. echo cfq > /sys/block/sda/queue/scheduler

  2. You can make a cron script that verifies the application start and change the scheduler accordingly.

You must log in to answer this question.