cgroup (control group) subsystem is the way to distribute and limit
system resources fairly. Each service in a modern linux system runs
under its own cgroup. You can use systemd-cgls and
systemd-top on systemd distributions, below,
atop and /sys/fs/cgroup/ to monitor cgroups.
cgroups have separate memory controls and memory event counters related
to these controls. The most useful of the cgroup memory controls are
memory.high and memory.low. cgroups have
separate PSI counters. These are available through
{memory,io,cpu}.pressure files. cgroup v2 has IO
controllers io.cost and io.latency, that help
with controlling disk operations and guarding from IO PSI spikes. Of
these two, the former is less invasive. You can use
systemd-run to create cgroups on the fly for ad-hoc tasks
that can be unpredictably heavy on IO. PSI is one of the better methods
of determining resource limits for a cgroup. Tools like
senpai can automatically set cgroup limits after observing
a service's pressure metrics under load.