Resource Manager is a monitoring feature that PolarDB uses to monitor the CPU utilization and the memory usage of clusters in real time. You can monitor resources from two dimensions: user threads and resource groups. You can monitor the CPU utilization and the memory usage in real time to obtain the real-time running status of your system. This way, you can identify the sources of system loads, and distribute the loads by scheduling your business. This topic describes how to use the Resource Manager feature.

Prerequisites

The version of the PolarDB cluster is ApsaraDB PolarDB MySQL-compatible edition 8.0 and the revision version is 8.0.2.1.0 or later.

Note For more information about how to upgrade the revision version, see Upgrade versions.

Precautions

  • If the thread pool feature is enabled, the CPU and memory statistics are inaccurate. Therefore, the switch parameter resource_group_enabled of Resource Manager and the switch parameter loose_thread_pool_enabled of the thread pool cannot be enabled at the same time.
  • Custom resource groups cannot be configured. After all the user threads are connected, they belong to the user_default resource group. The background threads of the system belong to the sys_default resource group.

Parameter configuration

The following table describes the parameters that you can specify for the Resource Manager feature.

Note
  • If you need to enable the Resource Manager feature, you must set the following three parameters to ON: resource_group_enabled, performance_schema, and cpu_usage_capture_enabled.
  • After you specify the three parameters: resource_group_enabled, performance_schema, and cpu_usage_capture_enabled, the new parameter values take effect only when all the nodes in the cluster are restarted. For more information about how to restart the nodes, see Restart a node. We recommend that you make appropriate business arrangements before you restart the nodes. Use caution if you need to restart the nodes.
Parameter Valid value Description
resource_group_enabled

ON or OFF

Default value: OFF.

Specifies whether to enable the Resource Group feature.
performance_schema

ON or OFF

Default value: OFF.

Specifies whether to enable the Performance Schame feature.
cpu_usage_capture_enabled

ON or OFF

Default value: OFF.

Specifies whether to enable the CPU utilization collection feature.
cpu_usage_capture_interval

100~1000

Default value: 500.

The interval at which you collect the CPU utilization. Unit: ms.

This parameter indicates the minimum interval between two contiguous CPU utilization collections.

cpu_usage_summarize_interval

1000~ULONG_MAX

Default value: 2000.

The interval at which the CPU utilization statistics are collected. Unit: ms.

This parameter specifies that the CPU utilization that the system displays in the query results is the average CPU utilization during the specified interval in the past.

performance_schema_minimal

ON or OFF

Default value: OFF.

Specifies whether to minimize the memory usage of performance_schema.

After you set performance_schema to ON, the performance-related statistics are collected by default. This affects performance. Therefore, if you need to mitigate the impact of the performance_schema parameter on system performance, we recommend that you set the performance_schema_minimal parameter to ON.

Note You can specify this parameter only when the performance_schema parameter is set to ON.

Resource monitoring

  • You can run the following commands to query the resources that are used by threads:
    call db_resource_manager.show_processlist();
    call db_resource_manager.show_processlist_verbose();
    Note
    • When you run the show_processlist command, the system cannot separately display the information about subthreads in the query results. Instead, the resources that are used by the parallel subthreads are added to the main thread so that the system can display the resources of the parallel subthreads and the main thread in a unified manner. In this case, the CPU utilization may exceed 100%.
    • show_processlist_verbose separately displays the information about subthreads.
    1
    You can also run the following query commands to filter and sort query results:
    select * from information_schema.processlist_verbose order by cpu_ratio desc limit 10;
    select * from information_schema.processlist_verbose where time > 60 order by mem desc
  • You can run the following command to query all the resource groups in the current system, and the resource group configurations:
    select * from information_schema.resource_group;
    Note Before you query the information, you must set the resource_group_enabled parameter to ON. For more information, see Parameter configuration.

Impact on performance

After the Resource Manager feature is enabled, the performance of PolarDB clusters is slightly affected. In addition, if you enable the performance_schema parameter, a large number of performance-related statistics are collected by default. This has a significant impact on the performance.

Test results

The following results are concluded from the preceding Sysbench performance test:

  • When you enable the Resource Manager feature and set the performance_schema_minimal parameter to OFF, the performance is significantly affected and decreases by about 8%. This result is obtained when you compare the performance with the performance in the scenario where the Resource Manager feature is disabled. If you set each of the performance_schema and resource_group_enabled parameters to ON, the Resource Manager feature is enabled. If you use the default value OFF for each of the performance_schema and resource_group_enabled parameters, the Resource Manager feature is disabled.
  • When you enable the Resource Manager feature but set the performance_schema_minimal parameter to ON, the performance is slightly affected and decreases by about 2%. This result is obtained when you compare the performance with the performance in the scenario where the Resource Manager feature is disabled. If you set each of the performance_schema and resource_group_enabled parameters to ON, the Resource Manager feature is enabled. If you use the default value OFF for each of the performance_schema and resource_group_enabled parameters, the Resource Manager feature is disabled.
Note
  • If you need to mitigate the impact of the performance_schema parameter on system performance, we recommend that you set the performance_schema_minimal parameter to ON.
  • In the preceding test, Sysbench is used to test the ApsaraDB PolarDB MySQL-compatible edition cluster whose specification is 8 cores and 32 GB. The impact on performance varies based on instance configurations and application scenarios.