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.
bdi
interface requires major:minor info. It can be figured out withfindmnt
andlsblk
. Note that in case of RAID, one mount point can be backed by multiple devices. – Mikko Rantalainen May 17 '17 at 11:13bdi
settings are not as effective as you hoped for, and will not really protect you. https://unix.stackexchange.com/a/481356/29483 – sourcejedi Nov 17 '18 at 23:21