Set control group
background information
The core of openGauss resource load management is the resource pool. To configure the resource pool, you must first set the control group Cgroups in the environment. For more information on the principle of Cgroups, please refer to the product manual of the relevant operating system.
The Class control group is the top-level control group where the database business runs. The default sub Class control group "DefaultClass" will be automatically generated during cluster deployment. The DefaultClass's Medium control group contains jobs triggered by the system running. This control group does not allow resource modification, and the jobs running on this control group are not controlled by resource management. Therefore, it is recommended to create a new sub Class and its Workload control group to set the resource ratio.
prerequisite
I am familiar with the use of "server Tools > gs_cgroup" and "server Tools > gs_ssh" in the tool reference.
Operation steps
explain:
- In openGauss, you need to create, update, and delete control groups on each cluster node to control the entire cluster resources. Therefore, the following steps are executed using the command "server Tools > gs\u SSH" in the tool reference.
- The naming requirements for the control group are as follows:
- The character ':' is not allowed in the name of either a subclass control group or a Workload control group.
- You cannot create a control group with the same name.
Create sub Class control group and Workload control group
1. Log in to the openGauss master node as the operating system user omm.
2. Create a sub Class control group named "class_a" and "class_b". The CPU resource quota is 40% and 20% of Class respectively.
gs_ssh -c "gs_cgroup -c -S class_a -s 40"
gs_ssh -c "gs_cgroup -c -S class_b -s 20"
3. Create a Workload control group named "workload_a1" and "workload_a2" under the sub Class control group "class_a". The CPU resource quota is 20% and 60% of the "class_a" control group respectively.
gs_ssh -c "gs_cgroup -c -S class_a -G workload_a1 -g 20 "
gs_ssh -c "gs_cgroup -c -S class_a -G workload_a2 -g 60 "
4. Create a Workload control group named "workload_b1" and "workload_b2" under the sub Class control group "class_b". The CPU resource quota is 50% and 40% of the "class_b" control group respectively.
gs_ssh -c "gs_cgroup -c -S class_b -G workload_b1 -g 50 "
gs_ssh -c "gs_cgroup -c -S class_b -G workload_b2 -g 40 "
Update resource quota for control group
1. Update the CPU resource quota of the "class_a" control group to 30%.
gs_ssh -c "gs_cgroup -u -S class_a -s 30"
2. Update the CPU resource quota of "workload_a1" under "class_a" to 30% of "class_a".
gs_ssh -c "gs_cgroup -u -S class_a -G workload_a1 -g 30"
Note: the CPU resources occupied by the adjusted Workload control group "workload_a1" should not be greater than its corresponding sub Class control group "class_a". In addition, this name cannot be the default name of Timeshare Cgroup, such as "Low", "Medium", "High" or "Rush".
Delete control group
gs_ssh -c "gs_cgroup -d -S class_a"
The above operations can delete the control group "class_a".
Note: the root user or the user with root access authority specifies "-d" and "-U username" to delete the default Cgroups that the ordinary user "username" can access. Ordinary users can delete existing Class Cgroups by specifying "-d" and "-S classname".
View control group information
1. View the control group information in the configuration file.
gs_cgroup -p
Control group configuration information
gs_cgroup -p Top Group information is listed: GID: 0 Type: Top Percent(%): 1000( 50) Name: Root Cores: 0-47 GID: 1 Type: Top Percent(%): 833( 83) Name: Gaussdb:omm Cores: 0-20 GID: 2 Type: Top Percent(%): 333( 40) Name: Backend Cores: 0-20 GID: 3 Type: Top Percent(%): 499( 60) Name: Class Cores: 0-20 Backend Group information is listed: GID: 4 Type: BAKWD Name: DefaultBackend TopGID: 2 Percent(%): 266(80) Cores: 0-20 GID: 5 Type: BAKWD Name: Vacuum TopGID: 2 Percent(%): 66(20) Cores: 0-20 Class Group information is listed: GID: 20 Type: CLASS Name: DefaultClass TopGID: 3 Percent(%): 166(20) MaxLevel: 1 RemPCT: 100 Cores: 0-20 GID: 21 Type: CLASS Name: class1 TopGID: 3 Percent(%): 332(40) MaxLevel: 2 RemPCT: 70 Cores: 0-20 Workload Group information is listed: GID: 86 Type: DEFWD Name: grp1:2 ClsGID: 21 Percent(%): 99(30) WDLevel: 2 Quota(%): 30 Cores: 0-5 Timeshare Group information is listed: GID: 724 Type: TSWD Name: Low Rate: 1 GID: 725 Type: TSWD Name: Medium Rate: 2 GID: 726 Type: TSWD Name: High Rate: 4 GID: 727 Type: TSWD Name: Rush Rate: 8 Group Exception information is listed: GID: 20 Type: EXCEPTION Class: DefaultClass PENALTY: QualificationTime=1800 CPUSkewPercent=30 GID: 21 Type: EXCEPTION Class: class1 PENALTY: AllCpuTime=100 QualificationTime=2400 CPUSkewPercent=90 GID: 86 Type: EXCEPTION Group: class1:grp1:2 ABORT: BlockTime=1200 ElapsedTime=2400
The control group configuration information viewed in the above example is shown in Table 1.
Table 1 control group configuration information
2. View the control group information of the tree structure in the operating system.
Execute the following commands to query the control group tree structure information.
gs_cgroup -P
The returned information is as follows, where shares represents the value of the dynamic resource quota "cpu.shares" of CPU resources in the operating system, and CPUs represents the value of the dynamic resource quota "cpuset.cpus" of CPUSET resources in the operating system, which refers to the range of cores that can be used by the control group.
Mount Information: cpu:/dev/cgroup/cpu blkio:/dev/cgroup/blkio cpuset:/dev/cgroup/cpuset cpuacct:/dev/cgroup/cpuacct Group Tree Information: - Gaussdb:wangrui (shares: 5120, cpus: 0-20, weight: 1000) - Backend (shares: 4096, cpus: 0-20, weight: 400) - Vacuum (shares: 2048, cpus: 0-20, weight: 200) - DefaultBackend (shares: 8192, cpus: 0-20, weight: 800) - Class (shares: 6144, cpus: 0-20, weight: 600) - class1 (shares: 4096, cpus: 0-20, weight: 400) - RemainWD:1 (shares: 1000, cpus: 0-20, weight: 100) - RemainWD:2 (shares: 7000, cpus: 0-20, weight: 700) - Timeshare (shares: 1024, cpus: 0-20, weight: 500) - Rush (shares: 8192, cpus: 0-20, weight: 800) - High (shares: 4096, cpus: 0-20, weight: 400) - Medium (shares: 2048, cpus: 0-20, weight: 200) - Low (shares: 1024, cpus: 0-20, weight: 100) - grp1:2 (shares: 3000, cpus: 0-5, weight: 300) - TopWD:1 (shares: 9000, cpus: 0-20, weight: 900) - DefaultClass (shares: 2048, cpus: 0-20, weight: 200) - RemainWD:1 (shares: 1000, cpus: 0-20, weight: 100) - Timeshare (shares: 1024, cpus: 0-20, weight: 500) - Rush (shares: 8192, cpus: 0-20, weight: 800) - High (shares: 4096, cpus: 0-20, weight: 400) - Medium (shares: 2048, cpus: 0-20, weight: 200) - Low (shares: 1024, cpus: 0-20, weight: 100) - TopWD:1 (shares: 9000, cpus: 0-20, weight: 900)
3. Obtain control group configuration information through the system view.
a. Use gsql to connect to the database.
b. Get the configuration information of all control groups in the system.
openGauss=# SELECT * FROM gs_all_control_group_info;
Create resource pool
background information
openGauss supports partitioning host resources by creating resource pools. After enabling resource load management, only using the default resource pool can not meet the demands of business on resource load management. You must create a new resource pool as needed to reallocate system resources to meet the needs of actual business for fine management of system resources. See Table 1 for the characteristics of common resource pool.
Table 1 Characteristics of common resource pool
Resource pool classification | characteristic |
---|---|
Common resource pool (common scenario) | 1. Associate Workload control groups. And there must be no group resource pool associated with the child class corresponding to the control group. That is, if the business resource pool association control group 'class1:wd' is created, there must be no group resource pool Association 'Class1'. 2,mem_percent is 0% by default, and there is no mem_percent adds less than 100% of the limit. |
After the resource load management function is enabled, the system will automatically create a default_pool. When a session or user does not specify an associated resource pool, it will be associated to default by default_pool. default_pool is bound to the DefaultClass:Medium control group by default, and does not limit the concurrency of associated businesses. default_ The detailed attributes of pool are shown in Table 2.
Table 2 default_pool attribute
attribute | Attribute value | explain |
---|---|---|
respool_name | default_pool | Resource pool name. |
mem_percent | 100 | Maximum percentage of memory consumed. |
cpu_affinity | -1 | CPU affinity, reserved parameters. |
control_group | DefaultClass:Medium | The control group associated with the resource pool. |
active_statements | -1 | The maximum number of concurrency allowed for the resource pool- 1 means unlimited concurrent quantity. |
max_dop | 1 | After SMP is enabled, the concurrency of operator execution is maintained. |
memory_limit | 8GB | Maximum memory usage, parameters reserved. |
parentid | 0 | Parent resource pool OID. |
io_limits | 0 | The maximum number of IO triggers per second. The line deposit unit is 10000 times /s, and the column deposit is times /s. 0 means no control. |
io_priority | None | When the IO utilization is up to 90%, the priority level associated with IO resource management and control by re consuming IO jobs. None means no control. |
nodegroup | installation | The name of the logical cluster where the resource pool is located. |
is_foreign | f | The resource pool is not used for users outside the logical cluster. |
Note: openGauss does not allow default_ Modify the pool parameter.
prerequisite
Familiar with the use of CREATE RESOURCE POOL, ALTER RESOURCE POOL and DROP RESOURCE POOL syntax.
Operation process
Create resource pool
1. Use gsql to connect to the database.
2. Create a group resource pool to associate with the specified sub Class control group. For example, the following: the group resource pool named "resource_pool_a" is associated with the "class_a" control group.
openGauss=# CREATE RESOURCE POOL resource_pool_a WITH (control_group='class_a'); openGauss=# CREATE RESOURCE POOL resource_pool_b WITH (control_group='class_b'); CREATE RESOURCE POOL
3. Create a business resource pool associated to the specified Workload control group. For example, the following: the business resource pool named "resource_pool_a1" is associated with the "workload_a1" control group.
openGauss=# CREATE RESOURCE POOL resource_pool_a1 WITH (control_group='class_a:workload_a1'); openGauss=# CREATE RESOURCE POOL resource_pool_a2 WITH (control_group='class_a:workload_a2'); openGauss=# CREATE RESOURCE POOL resource_pool_b1 WITH (control_group='class_b:workload_b1'); openGauss=# CREATE RESOURCE POOL resource_pool_b2 WITH (control_group='class_b:workload_b2'); CREATE RESOURCE POOL
explain:
- If the associated control group is not specified when creating a resource pool, the resource pool will be associated to the default control group (the "Medium" Timeshare control group under the DefaultClass control group).
- control_ The group value is case sensitive. Single quotation marks should be used when specifying.
- If the database user specifies the string represented by the timeshare control group, that is, one of "Rush", "High", "Medium" or "Low", such as control_ The string of group is "High", which represents that the resource pool is assigned to the "High" Timeshare control group under the DefaultClass control group.
- control_group can specify that a user create a Workload control group, that is, 'class1:wd', or it can have a control group level, for example, 'class1:wd:2'. This level must be in the range of 1-10, but this level will not make any distinction. In the old version, it was allowed to create a Workload control group with the same name to distinguish by level. However, after the new version is upgraded, it is not allowed to create a control group with the same name. If a user has created a Workload control group with the same name in the old version, its level will not be distinguished during the use process. This may cause the problem that the control group is not clearly used. The user needs to delete the old control group with the same name to clearly use the control group.
Manage resource pools
Modify the properties of the resource pool. For example, the following: modify the control group associated with the resource pool "resource_pool_a2" to "class\u a:workload\u A1" (assuming that class\u a:workload\u A1 is not associated with other resource pools).
openGauss=# ALTER RESOURCE POOL resource_pool_a2 WITH (control_group="class_a:workload_a1"); ALTER RESOURCE POOL
Delete resource pool
Delete the resource pool. For example, delete the resource pool "resource_pool_a2" below.
openGauss=# DROP RESOURCE POOL resource_pool_a2; DROP RESOURCE POOL
explain:
- If a role is already associated with the resource pool, it cannot be deleted.
- In the multi tenant scenario, if the group resource pool is deleted, its business resource pool will be deleted. The resource pool can be deleted only when no user is associated.
View resource pool information
Notice:
1. INSERT, UPDATE, DELETE, TRUNCATE are not allowed to operate the system table PG of resource load management_ resource_ pool.
2. Modifying memory of resource pool is not allowed_ Limit and cpu_affinity attribute.
- View all resource pool information in the current cluster.
openGauss=# SELECT * FROM PG_RESOURCE_POOL;
respool_name | mem_percent | cpu_affinity | control_group | active_statements | max_dop | memory_limit | parentid | io_limits | io_priority | nodegroup | is_foreign | max_worker ------------------+-------------+--------------+---------------------+-------------------+---------+--------------+----------+-----------+--------------+--------------+------------ default_pool | 100 | -1 | DefaultClass:Medium | -1 | 1 | 8GB | 0 | 0 | None | installation | f | resource_pool_a | 20 | -1 | class_a | 10 | 1 | 8GB | 0 | 0 | None | installation | f | resource_pool_b | 20 | -1 | class_b | 10 | 1 | 8GB | 0 | 0 | None | installation | f | resource_pool_a1 | 20 | -1 | class_a:workload_a1 | 10 | 1 | 8GB | 16970 | 0 | None | installation | f | resource_pool_a2 | 20 | -1 | class_a:workload_a2 | 10 | 1 | 8GB | 16970 | 0 | None | installation | f | resource_pool_b1 | 20 | -1 | class_b:workload_b1 | 10 | 1 | 8GB | 16971 | 0 | None | installation | f | resource_pool_b2 | 20 | -1 | class_b:workload_b2 | 10 | 1 | 8GB | 16971 | 0 | None | installation | f | (7 rows)
- View the control group information associated with a resource pool. For details, refer to GS in the statistics function section_ control_ group_ Info (pool text) function.
"resource_pool_a1" in the following command is the name of the resource pool.
openGauss=# SELECT * FROM gs_control_group_info('resource_pool_a1');
name | class | workload | type | gid | shares | limits | rate | cpucores ---------------------+---------+-------------+-------+-----+--------+--------+------+---------- class_a:workload_a1 | class_a | workload_a1 | DEFWD | 87 | 30 | 0 | 0 | 0-3 (1 row)
Table 3 gs_control_group_info attribute
attribute | Attribute value | explain |
---|---|---|
name | class_a:workload_a1 | class and workload name |
class | class_a | Class control group name |
workload | workload_a1 | Workload control group name |
type | DEFWD | Control group type (Top, CLASS, BAKWD, DEFWD, TSWD) |
gid | 87 | Control group id |
shares | 30 | Percentage of parent node CPU resources |
limits | 0 | Percentage of parent node CPU cores |
rate | 0 | Allocation proportion in Timeshare |
cpucores | 0-3 | Number of CPU cores |
Author: Gauss squirrel Club