Control group [cgroup] limit the system resources

Hello DevOps team, in this post I will be exploring the CGroup usage in docker engine.



How check CGroup in the Linux file system supporting?
To check all types of cgroups that are allowed in Linux system we can check at /sys/fs/cgroup directory

What's the default memory limit for docker containers?
Interestingly, when you don't define any control group on the memory limits, the docker engine will allocate the full memory of the VM as the maximum memory limit.

How do we impose the container memory limits?
When you run the container with the 100m upper memory limit for the tomcat image. You can see the limit value docker stats command.

Can we control of CPU load per container? How?
Yes it is possible to control the CPUs usage to container.
Control group helps us in define the limit, this can be decimal values that indicate CPU cycles - example here with 0.1

We can apply both the control group limits on the same container.

How to get the version of Cgroup
 We can get the control group version and Driver value using `docker info` command.
We can have CPU Sets for creating new containers where we can share it with the other container as well. Here is an example, container lopri can be used with --cpuset-cpus=0 and share percentage using --cpu-shares=20 for busybox image. note that when no other container is running the whole CPU % will be alloted to the single container. When we have multiple container shares then it will be distributed the CPU as per the shares defined.
--cpu-shares int option will be used to define the CPU shares (relative weight) 

 --cpuset-cpus string option will be used for CPUs in which to allow execution (0-3, 0,1) 

 -cpu-quota int option will be used to set the Limit CPU CFS (Completely Fair Scheduler) quota Here the CPU cfs quota can not be less than 1ms (i.e. 1000).
using --cpu-quota option container creation

Comments

Popular posts from this blog

Ansible Jinja2 Templates: A Complete Guide with Examples

Ansible 11 The uri module with examples

DevOps Weapons