Help Center > > Developer Guide> Resource Load Management> Resource Management Preparation> Creating a Resource Pool

Creating a Resource Pool

Updated at: Sep 17, 2021 GMT+08:00

Context

GaussDB(DWS) creates resource pools to divide host resources. After resource load management is enabled, the default resource pool is insufficient to address the resource load management requirements of services. Therefore, new resource pools must be used to reallocate system resources to address the requirements. In multi-tenant scenarios, two-level resource pools (group and service resource pools) are used to manage resources. Table 1 describes the characteristics of different types of resource pools.

Table 1 Resource pool characteristics

Resource Pool

Characteristic

Group resource pool (multi-tenant scenario)

  • A group resource pool is associated with a sub-Class Cgroup and can be created only when no resource pool is associated with a Workload Cgroup under the current sub-Class Cgroup.
  • The default value of mem_percent for each group resource pool is 20%. The sum of mem_percent for all resource pools is less than or equal to 100%.
  • Group resource pools must be isolated. That is, you cannot create two resource pools both associated with the same Class Cgroup.
  • A group resource pool can be used only by the group user, which is unique.

Service resource pool (multi-tenant scenario)

  • A service resource pool is associated with a Workload Cgroup, and its group resource pool must be associated with the corresponding sub-Class Cgroup. For example, to create a service resource pool and associate it with class1:wd, ensure that its group resource pool has been associated with class1.
  • The default value of mem_percent for each service resource pool is 20%. The sum of mem_percent for all service resource pools under the same group resource pool is less than or equal to 100%.
  • Multiple service resource pools can be associated with the same Timeshare Cgroup (Low, Medium, High, or Rush). That is, you can create two service resource pools both associated with class:High.
  • Service resource pools that are not associated with Timeshare Cgroups are forcibly isolated from each other. If you have created the class:wd Cgroup, you cannot create two service resource groups both associated with it.
  • A service resource pool can be used by multiple service users.

Common resource pool (common scenario)

  • A common resource pool is associated with a Workload Cgroup, and its group resource pool must not be associated with the corresponding sub-Class Cgroup. For example, to create a service resource pool and associate it with class1:wd, ensure that its group resource pool has not been associated with class1.
  • The default value of mem_percent is 0. The sum of mem_percent for all common resource groups under the same group resource pool can be greater than or equal to 100%.

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. default_pool is bound to the DefaultClass:Medium Cgroup, and the concurrency and memory are not controlled by default. default_pool parameters can be modified, but jobs associated with default_pool are restricted by the max_active_statements specified global concurrency. If management and control is not required for administrator's O&M operations, run the SET session_respool='root'; command before running SQL statements to switch the resource pool to the O&M queue, so that jobs are not restricted. Table 2 describes the attributes of default_pool.

Initial users are not subject to resource control.

Table 2 default_pool attributes

Attribute

Value

Description

respool_name

default_pool

Name of the resource pool

mem_percent

0

Maximum percentage of used memory 0 indicates that there are no limitations.

cpu_affinity

-1

CPU affinity (reserved)

control_group

DefaultClass:Medium

Cgroup associated with the resource pool

active_statements

-1

Maximum number of concurrent queries allowed by the resource pool. -1 and 0 indicate that there are no limitations.

max_dop

-1

Concurrency of operators after SMP is started. This is a reserved parameter.

memory_limit

default

Estimated memory limit of jobs in the resource pool. default indicates that the memory limit is half of the resource pool memory. unlimited indicates that the memory size is not limited.

parentid

0

OID of the parent resource pool

io_limits

0

Upper limit of IOPS. It is counted by ones for column storage and by 10 thousands for row storage. The value 0 means no limit.

io_priority

None

I/O priority set for jobs that consume many I/O resources. It takes effect when the I/O usage reaches 90%. None means no control.

nodegroup

installation

The logical cluster to which the resource pool belongs. installation indicates that the resource pool belongs to a non-logical cluster.

is_foreign

f

External resource pool or not

short_acc

t

Enables short query acceleration or not.

except_rule

None

Exception rule associated with the resource pool

  • The number of concurrent services associated with the default_pool resource pool is restricted by the global concurrency parameter max_active_statements.
  • session_respool can only be set by the administrator in a session.

Prerequisites

You are familiar with the ALTER RESOURCE POOL, CREATE RESOURCE POOL, and DROP RESOURCE POOL syntax.

Procedure

Creating a resource pool

  1. 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.

    1
    2
    3
    CREATE RESOURCE POOL resource_pool_a WITH (control_group='class_a');
    CREATE RESOURCE POOL resource_pool_b WITH (control_group='class_b');
    CREATE RESOURCE POOL
    

  1. 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.

    1
    2
    3
    4
    5
    CREATE RESOURCE POOL resource_pool_a1 WITH (control_group='class_a:workload_a1');
    CREATE RESOURCE POOL resource_pool_a2 WITH (control_group='class_a:workload_a2');
    CREATE RESOURCE POOL resource_pool_b1 WITH (control_group='class_b:workload_b1');
    CREATE RESOURCE POOL resource_pool_b2 WITH (control_group='class_b:workload_b2');
    CREATE RESOURCE POOL
    
    • 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 ('').
    • If a database user specifies the Timeshare string (Rush, High, Medium, or Low) in the syntax, for example, if control_group is set to High, the resource pool will be associated with the High Timeshare Cgroup under DefaultClass.

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).
1
2
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:

1
2
DROP RESOURCE POOL resource_pool_a2;
DROP RESOURCE POOL
  • 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 corresponding service resource pools. A resource pool can be deleted only when it is not associated with any users.

Viewing Resource Pool Information

  • Do not use the INSERT, UPDATE, DELETE, or TRUNCATE statements to perform operations on the system catalog pg_resource_pool recording resource load management data. Otherwise, the catalog content queried through different CNs may be inconsistent.
  • Do not modify the cpu_affinity attribute of a resource pool.
  • View all the resource pool information of the current cluster.
    1
    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 | short_acc |
    except_rule
    ------------------+-------------+--------------+---------------------+-------------------+---------+--------------+----------+-----------+-------------+--------------+------------+-----------+-
    ------------
     default_pool     |         100 |           -1 | DefaultClass:Medium |                -1 |      -1 | unlimited    |        0 |         0 | None        | installation | f          | t         |
     resource_pool_a  |          20 |           -1 | class_a             |                10 |      -1 | default      |        0 |         0 | None        | installation | f          | t         |
    None
     resource_pool_b  |          20 |           -1 | class_b             |                10 |      -1 | default      |        0 |         0 | None        | installation | f          | t         |
    None
     resource_pool_a1 |          20 |           -1 | class_a:workload_a1 |                10 |      -1 | default      |    28334 |         0 | None        | installation | f          | t         |
    None
     resource_pool_a2 |          20 |           -1 | class_a:workload_a2 |                10 |      -1 | default      |    28334 |         0 | None        | installation | f          | t         |
    None
     resource_pool_b1 |          20 |           -1 | class_b:workload_b1 |                10 |      -1 | default      |    28335 |         0 | None        | installation | f          | t         |
    None
     resource_pool_b2 |          20 |           -1 | class_b:workload_b2 |                10 |      -1 | default      |    28335 |         0 | None        | installation | f          | t         |
    None
    (7 rows)
  • View information about Cgroups associated with a resource pool. For details, see gs_control_group_info(pool text) in the statistics information function.
    In the following example, resource_pool_a1 is the name of the resource pool.
    1
    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

    Attribute

    Value

    Description

    name

    class_a:workload_a1

    Class name and workload name

    class

    class_a

    Class Cgroup name

    workload

    workload_a1

    Workload Cgroup name

    type

    DEFWD

    Cgroup type (Top, CLASS, BAKWD, DEFWD, and TSWD)

    gid

    87

    Cgroup ID

    shares

    30

    Percentage of CPU resources to those on the parent node

    limits

    0

    Percentage of CPU cores to those on the parent node

    rate

    0

    Allocation ratio in Timeshare

    cpucores

    0-3

    Number of CPU cores

Did you find this page helpful?

Submit successfully!

Thank you for your feedback. Your feedback helps make our documentation better.

Failed to submit the feedback. Please try again later.

Which of the following issues have you encountered?







Please complete at least one feedback item.

Content most length 200 character

Content is empty.

OK Cancel