5

Given a busy system with a really fast block device (highend NVMe raid, 2 GB/s write, 4 GB/s read) mounted at /data and an a really slow device (USB HDD with spinning 8 TB disk, 50 MB/s write, 60 MB/s read) mounted at /backup, how can I limit processes reading from and writing to /backup without sacrificing I/O of /data?

As far as I know, the problem is that linux only has global knobs dirty_background_bytes and dirty_bytes. If I set those limits to sensible values for NVMe (around 2 GB and 4 GB in practice) the throughput is fine until a process (e.g. rsync) starts to write to USB with lots of data. In that case dirty_background is filled with data going to USB device and rsync is stopped from dirtying more pages. However, that causes processes writing to fast devices to be aggressively slowed down because dirty_background is global limit and shared between fast and slow devices. I know that I can limit dirty bytes according to slowest device connected to the system and that will avoid huge stalls but will sacrifice some throughput of the faster devices.

Is there equivalent of dirty_background_bytes for a single block device? It really makes zero sense to slow down all processes writing to /data in case /backup is slow and accessed by some other process.

I know that cgroup can be used to do this manually (How to Throttle per process I/O to a max limit?). However, I would like to adjust this per block device and all processes accessing said devices should be throttled down before slowing down the whole system. If a process writes to both fast and slow devices, it should get slowed down only if it's writing too much to the slow device.

4
  • 1
    Possibly the thing I'm looking for is /sys/class/bdi/*/max_ratio - see unix.stackexchange.com/a/338317/20336 for more info. Commented May 17, 2017 at 10:39
  • The bdi interface requires major:minor info. It can be figured out with findmnt and lsblk. Note that in case of RAID, one mount point can be backed by multiple devices. Commented May 17, 2017 at 11:13
  • 1
    I think the bdi settings are not as effective as you hoped for, and will not really protect you. unix.stackexchange.com/a/481356/29483 Commented Nov 17, 2018 at 23:21
  • See also: unix.stackexchange.com/q/714267/20336 Commented Sep 12, 2022 at 9:40

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.