Creating a Resource Pool
Background
openGauss creates resource pools to divide host resources. After resource load management is enabled, the default resource pool alone is insufficient to address the resource load management requirements of services. Therefore, new resource pools must be used to reallocate system resources for granular control purposes. Table 1 describes the features of a common resource pool.
Table 1 Features of a common resource pool
After resource load management is enabled, the system automatically creates default_pool. If no resource pool is specified for a session or user, they will be automatically associated with default_pool. By default, default_pool is associated with the DefaultClass:Medium Cgroup and does not limit the number of concurrent services. Table 2 describes the attributes of default_pool.
Table 2 default_pool attributes
NOTICE: default_pool cannot be modified in openGauss.
Prerequisites
You are familiar with the CREATE RESOURCE POOL, ALTER RESOURCE POOL, and DROP RESOURCE POOLsyntax.
Procedure
Creating a resource pool
Perform the steps in gsql connection and usage.
Create a group resource pool and associate it with the specified sub-Class Cgroup. In the following example, the group resource pool named resource_pool_a is associated with the class_a Cgroup.
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
Create a service resource pool and associate it with the specified Workload Cgroup. In the following example, the service resource pool named resource_pool_a1 is associated with the workload_a1 Cgroup.
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
NOTE:
- If you do not specify an associated Cgroup when creating a resource pool, the resource pool will be associated with the default Cgroup, which is the Timeshare Cgroup Medium under the DefaultClass Cgroup.
- The value of control_group is case-sensitive and must be contained in single quotation marks or double quotation marks.
- If a database user specifies the Timeshare string (Rush, High, Medium, or Low) in the syntax, for example, control_group is set to High, the resource pool will be associated with the High Timeshare Cgroup under DefaultClass.
- control_group allows you to create a Workload Cgroup, for example, class1:wd whose Cgroup level can also be appended, such as class1:wd:2. The Cgroup level must be within 1 to 10, but it is not used for Cgroup differentiation. In earlier versions, you can create Workload Cgroups with the same name and differentiate them by their levels. In the latest version, Cgroup names must be unique. If you have created duplicate Workload Cgroups in an earlier version, delete them to avoid confusion.
Managing resource pools
Modify resource pool attributes. In the following example, the Cgroup associated with the resource pool resource_pool_a2 is changed to class_a:workload_a1 (assuming that class_a:workload_a1 is not associated with any other resource pools).
openGauss=# ALTER RESOURCE POOL resource_pool_a2 WITH (control_group="class_a:workload_a1");
ALTER RESOURCE POOL
Deleting a resource pool
Delete a resource pool. For example, run the following command to delete the resource pool resource_pool_a2:
openGauss=# DROP RESOURCE POOL resource_pool_a2;
DROP RESOURCE POOL
NOTE:
- The resource pool cannot be deleted if it is associated with a role.
- In a multi-tenant scenario, deleting a group resource pool also deletes the related service resource pools. A resource pool can be deleted only when it is not associated with any users.
Viewing Resource Pool Information
NOTICE:
- Do not use the INSERT, UPDATE, DELETE, and TRUNCATE statements in the pg_resource_pool system catalog that manages resource load.
- Do not modify the memory_limit and cpu_affinity attributes of a resource pool.
Run the following command to view the information of all the resource pools of 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 information about Cgroups associated with a resource pool. For details, see statistics-information-functions.
In the following example, resource_pool_a1 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 attributes