Neither with cgroups one can easily say “use maximum hard limit of xx % of available system resources (CPU, RAM, IO) for this application”.
Maxmium RAM can be a hard limit such as xxxx MB.
Throttling a device IO (virtual) (harddrive) syntax is <major>:<minor> <bytes_per_second>
. See https://lqhl.me/blog/2015/09/09/network-disk-bandwidth-limiting-on-linux/. Also a hardcoded value. Which value to choose? One would have to benchmark the disk first before deciding on a reasonable value. Also finding out <major>:<minor>
is non-trivial from a script.
It seems cgroups resource moderation is more useful to say “within this cgroup this application can use xx % of CPU”. This might be useful when implementing this for the whole system.
Maybe just combining ionice
with nice
would be a good enough hack. I.e.
ionice --class 3 nice -n 19 application-name
But that wouldn’t limit maximum RAM the application can use. And once RAM is exhausted, system will probably freeze or get so slow that one would loose patience and reboot.
Would be best if Debian had this implemented for the whole system. For example guaranteeing that X always has sufficient system resources and cannot be starved by a broken application.