Resource Management Preparation（2）
Tags: opengauss
Published: 2023-04-17 09:47:31

**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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d7bezo1gw84n6h5dncyb.png)

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hwn0ttfp3eduqxde5eis.png)

**Prerequisites**
You are familiar with the CREATE RESOURCE POOL, ALTER RESOURCE POOL, and DROP RESOURCE POOLsyntax.

**Procedure**
**Creating a resource pool**
1. Perform the steps in Using gsql to Connect to a Database.

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s7ilx8xihdo2bmh9cyel.png)

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9wt3i09davzs2d7lpqcy.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/393ijmhxh1g4c1vxrtlm.png)

**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).

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x7a28za6qpva8uod176t.png)

Deleting a resource pool

Delete a resource pool. For example, run the following command to delete the resource pool **resource_pool_a2**:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/64os9p3xtjtvc69jbelm.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xdgheqllemcixw4egl4g.png)

**Viewing Resource Pool Information**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3zzdfs0oxuyoe40m4jqx.png)

Run the following command to view the information of all the resource pools of the current cluster:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tqs3md0g0xttiwdrowkz.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8zxq1b437esii54smzo6.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h1pzdp1gywmxt0zd5om9.png)

**·** 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.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wm4ygc0x740m66ve4ra6.png)

Table 3 gs_control_group_info attributes

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7x4cjyw996lc6e5ouew4.png)