Linux - Cgroups (Control Groups)

About

With cgroups, it's possible to allocate resources dynamically to process

Example

  • Installation (On CentOS)
sudo yum install -y \
   libcgroup \
   libcgroup-tools # the service

Management

List

lscgroup list all cgroups

Example:

  • list all cgroups which are in hierarchy containing cpu controller
lscgroup -g cpu:/
  • list all cgroups which are in hierarchy containing cpu controller in subgroup student
lscgroup -g cpu:/student
  • list all cgroups which in all hierarchies
lscgroup

Create

See cgcreate

Set

See cgset

Example

50% CPU

  • Create a group with the cpu scheme
sudo cgcreate -g cpu:/cpu_50
  • Set the shares of the CPU where the shares are a portion of the CPU utilization. Every process get by defaults 1024 shares
sudo cgset -r cpu.shares=512 cpu_50
  • Usage
sudo cgexec -g cpu:cpu_50 mybigcommand

Documentation / Reference


Powered by ComboStrap