Linux how to install and configure Cgroup

  

Cgroup full name control groups, can be used to limit, record, and isolate the physical resources of the process group, the following small series will be a detailed introduction to the installation and configuration of Cgroup on Linux, interested in Cgroup Friends can come and learn.

Why do you have a cgroup

There is often a need in Linux systems to limit the allocation of resources for one or some processes. That is, the concept of a set of containers can be completed. In this container, there is a specific proportion of cpu time allocated, IO time, available memory size, and so on. So the concept of cgroup appeared, cgroup is the controller group, originally proposed by google engineers, and later integrated into the Linux kernel.

Cgroup is a Linux kernel function that manages the management of any process. The cgroup itself provides the infrastructure for the functions and interfaces that manage the process of packets.

Then the Android operating system relies on this technology to assign different cgroups to each application, and to isolate each program, so that an application does not affect other application environments.

Concepts

task:

A process

control group:

Control group, process group according to certain criteria< Br>

hierarchy:

Hierarchy, the control group can form a tree structure with parent nodes and child nodes. Each node is a control group, and the child nodes inherit the specific properties of the parent node.

subsystem:

Subsystem.

The subsystem is the resource controller, and each subsystem is a resource allocator. For example, the cpu subsystem controls the CPU time allocation.

You can use lssubsys -al to list how much seed system support system, and use ls /sys /fs /cgroup /(Ubuntu) has been mounted to display subsystem:

You can see several subsystems here, such as cpu is to control cpu time slice, memory is to control memory usage.

How to install cgroup

Install cgroup:

apt-get install cgroup-bin

How to assign restricted resources to cgroup

First of all, understand that the subsystem is mounted first, and then there is a control group. This means that if you want to limit the resources of some processes, then I will first mount the memory subsystem, then create a cgroup node in the memory subsystem, in which the process id to be controlled will be written and will be controlled. The properties are written.

Take memory subsystem, for example:

By looking cgroup configuration file:

cat /etc/cgconfig.conf

see The memory subsystem is mounted in the directory /sys/fs/cgroup/memory

Enter this directory

Create a folder and create a control group

Mkdir test
Previous12Next page Total 2 pages

Copyright © Windows knowledge All Rights Reserved