4 ms·
On Linux we have something called "cgroups" which is integrated with the kernel's scheduler. Cgroups can be used to control and limit resources and do exactly w
by chlorion 4y ago
On Linux we have something called "cgroups" which is integrated with the kernel's scheduler. Cgroups can be used to control and limit resources and do exactly what you are describing!
Cgroups can be used to limit the maximum amount of CPU bandwidth a certain group can use in a given period with fairly high resolution. For example, you can use the cpu.max variable to limit a group to run for a maximum of 1000 microseconds per second (1s = 1000000us). You can also limit what cores the group can run on, and the "weight" of the group when CPU bandwidth is being contested by other groups!
Cgroups can also limit resources such as RAM, swap and IO in a similar way.
Systemd has some features to put daemons in cgroups and provides ways to set the various control variables which is pretty handy, and it also has a way to launch regular programs with resource controls applied with systemd-run. There is also libcgroup and the sysfs interface for systems without systemd.