Isolate resources with resource groups (to be deprecated)

更新时间:
复制 MD 格式

Hologres provides fine-grained resource management capabilities. You can allocate different computing resources, known as compute units (CUs) that include CPU and memory, to different user accounts. This allows you to set upper limits on resource usage for each user, isolate multiple workloads within a single instance, and prevent jobs from different users or applications from interfering with each other. This topic describes how to use resource groups to manage computing resources and implement resource isolation within a Hologres instance.

Background

Hologres versions V1.0 and earlier support resource isolation between instances, but not fine-grained, user-level resource isolation within an instance. In production environments, you often need to isolate resources by user within an instance and limit the maximum resource usage for each user to prevent jobs from interfering with each other. To meet these fine-grained resource isolation needs, Hologres introduced resource groups to manage computing resources within an instance and implement resource isolation. Due to current technical limitations, not all types of computing workloads can be isolated using resource groups. Use this feature with caution in a production environment. For a more robust resource isolation solution, we recommend using elastic virtual warehouses.

Limitations

  • You can use resource groups to manage computing resources only in Hologres instances of V1.1 or later. If your instance is an earlier version, see Troubleshooting upgrade preparation errors or join the Hologres DingTalk group for support. For more information, see How do I get more online support?.

  • Only users with superuser permissions can use resource groups to manage computing resources within a Hologres instance. Otherwise, the system reports a permission error.

  • Computing resources are managed at the instance level. If a user has multiple databases within one instance, all databases share the computing resources of that instance and are subject to the same resource allocation plan.

Configure resource groups in HoloWeb

Follow these steps to configure resource groups in the HoloWeb UI.

  • Create a resource group

    1. Connect to HoloWeb. For more information, see Connect to HoloWeb and run queries.

    2. In the top navigation bar of HoloWeb, click Security Center.

    3. On the Security Center page, click Resource Group Management in the navigation pane on the left.

    4. On the Resource Group Management page, select the target instance and click Add Resource Group.

    5. In the Add Resource Group dialog box, enter a Resource Group Name, set the Resource Group Quota, and click OK.

      Note

      The sum of quotas for all resource groups within a Hologres instance cannot exceed 1. Otherwise, the system reports an error.

  • Delete a resource group

    1. Connect to HoloWeb. For more information, see Connect to HoloWeb and run queries.

    2. In the top navigation bar of HoloWeb, click Security Center.

    3. On the Security Center page, click Resource Group Management in the navigation pane on the left.

    4. On the Resource Group Management page, find the resource group you want to delete and click Delete in the Actions column.

      Note

      You cannot delete a resource group that has associated users.

  • Adjust a resource group quota

    1. Connect to HoloWeb. For more information, see Connect to HoloWeb and run queries.

    2. In the top navigation bar of HoloWeb, click Security Center.

    3. On the Security Center page, click Resource Group Management in the navigation pane on the left.

    4. On the Resource Group Management page, find the target resource group and click Adjust Quota in the Resource Group Quota column.

    5. In the Adjust Quota dialog box, modify the resource group quota and click OK.

  • Associate a user

    After creating a resource group, you can associate users with it in HoloWeb.

    1. Connect to HoloWeb. For more information, see Connect to HoloWeb and run queries.

    2. In the top navigation bar of HoloWeb, click Security Center.

    3. On the Security Center page, click Resource Group Management in the navigation pane on the left.

    4. On the Resource Group Management page, find the target resource group and click Associate User in the Actions column.

    5. On the Associate Resource Group page, click Add User for Association.

    6. In the Associate User dialog box, select a user and click OK.

      Note
      • If a user you want to associate does not appear in the drop-down list, they have not been added to the current instance. You must first add them on the user management page.

      • A user can be associated with only one resource group. If you associate a user with a new resource group, the previous association is overwritten.

  • Disassociate a user

    1. Connect to HoloWeb. For more information, see Connect to HoloWeb and run queries.

    2. In the top navigation bar of HoloWeb, click Security Center.

    3. On the Security Center page, click Resource Group Management in the navigation pane on the left.

    4. On the Resource Group Management page, find the target resource group and click Associate User in the Actions column.

    5. On the Bind Resource Group page, click Disassociate User in the Actions column of the target user.

    6. In the Disassociate User dialog box, click OK.

Configure resource groups using SQL

  • View resource group configurations

    To view all resource groups, their configured quotas, and their associated users, run the following SQL statement:

    SELECT  * FROM pg_holo_resource_groups;

    Sample result:

     res_group_name | property_key |         property_value
    ----------------+--------------+------------------------------------------
     resource_1     | worker_limit | 0.3
     default        | worker_limit | 0.7
     resource_1     | bind_users   | [ "13xxxxxxxxx13", "p4_29xxxxxxxxxx19" ]                                       
  • Create a resource group

    Note
    • By default, the system creates a resource group named default, allocates all computing resources to it, and assigns all unassociated users to this group.

    • After you create other resource groups, the quota for the default resource group is automatically adjusted to the remaining portion.

    • We recommend that you allocate at least 30% of the total resources to the default resource group.

    Run the following SQL statement to create a resource group:

    CALL hg_create_resource_group ('resource_group_name', quota);

    Parameter

    Description

    resource_group_name

    The name of the resource group. The name can contain letters, digits, and underscores (_) and must be no more than 50 characters long.

    quota

    The percentage of resources allocated to the resource group. The value must be between 0.1 and 0.9, inclusive, and can have only one decimal place.

  • Modify a resource group quota

    Note

    The sum of the quotas for all resource groups within a Hologres instance cannot exceed 1. Otherwise, an error occurs.

    Run the following SQL statement to modify the quota of a resource group:

    CALL hg_alter_resource_group ('resource_group_name', quota);

    Parameter

    Description

    resource_group_name

    The name of the resource group. The resource group must exist. Otherwise, an error occurs.

    quota

    The percentage of resources allocated to the resource group. The value must be between 0.1 and 0.9, inclusive, and can have only one decimal place.

  • Delete a resource group

    Note

    You cannot delete a resource group that has associated users.

    Run the following SQL statement to delete a resource group:

    CALL hg_drop_resource_group ('resource_group_name');

    Parameter

    Description

    resource_group_name

    The name of the resource group. The resource group must exist. Otherwise, an error occurs.

  • Associate a user with a resource group

    Note
    • A user can be associated with only one resource group. If you associate a user with a new resource group, the previous association is overwritten.

    • You can run the following SQL statement to view the current user:

      SELECT current_user;

    After creating a resource group, you can associate users with it to limit their computing resources. Run the following SQL statement to associate a user with a resource group:

    • Syntax

      CALL hg_bind_resource_group('resource_group_name', 'user_name');
    • Parameters

      Parameter

      Description

      resource_group_name

      The name of the resource group. The resource group must exist. Otherwise, an error occurs.

      user_name

      The name of the user. The user must exist and have permissions to access the instance containing the resource group. Otherwise, an error occurs.

    • Examples

      CALL hg_bind_resource_group ('resource_1', 'p4_29xxxxxxxxxxx');
      -- Note: Alibaba Cloud account names must be enclosed in double quotation marks.
      CALL hg_bind_resource_group ('resource_1', '"ALIYUN$xxxx@aliyun.com"');
      CALL hg_bind_resource_group ('resource_1', '"RAM$xxx@xxx:xxxx"');
      CALL hg_bind_resource_group ('resource_1', '"13xxxxxxxxxxx13"');
  • Disassociate a user from a resource group

    Note

    After a user is disassociated from a resource group, they are automatically assigned to the default resource group.

    Run the following SQL statement to disassociate a user from a resource group:

    • Syntax

      CALL hg_unbind_resource_group('resource_group_name', 'user_name');
    • Parameters

      Parameter

      Description

      resource_group_name

      The name of the resource group. The resource group must exist. Otherwise, an error occurs.

      user_name

      The name of the user. The user must exist and have permissions to access the instance containing the resource group. Otherwise, an error occurs.

    • Examples

      CALL hg_unbind_resource_group ('resource_1', 'p4_29xxxxxxxxxxxxx9');
      -- Note: Alibaba Cloud account names must be enclosed in double quotation marks.
      CALL hg_unbind_resource_group ('resource_1', '"RAM$xxxx@xxx:xxx"');

FAQ

Q: Why do the CPU and memory metrics exceed 50% when the resource group quota is set to 0.5?

A: A resource group's quota primarily limits the CPU and memory used by the query engine. However, a small portion of CPU and memory usage is unrestricted to handle operations such as SQL parsing and optimization, metadata processing, scheduling, PQE execution, and compaction. Additionally, for real-time data writes, the quota limits CPU but not memory usage. Consequently, a resource group's total CPU and memory metrics can exceed its configured quota.