Thursday, 1 November 2018

Linux cgroups Resource Constraints

Linux cgroups (control groups) have been around for a long time providing varioius functions for resource management and the ability to segregate workloads with their own constraints. cgroups have provided the basis for container engines such as docker that has become so aggressively adopted in enterprises over the last few years.

cgroups are enabled on all contemporary linuxes with systemd being the API to manage them; the system will manage various cgroups organised in:
  • slices - see systemd-cgls where we will typically see system services under the system slice users services, including the segregation for user sessions in another. Encapsulates scopes and services.
  • scopes - parent for a logical grouping of units/services which can be managed (killed/stop/resource managed)
  • services - logical grouping that provides a service, such as the sshd, that are usual started based on configuration in unit files

But how can cgroup and resource controls be useful for a developer?