Skip to main content
Version: 3.0

CREATE RESOURCE GROUP

Description

Creates a resource group.

For more information, see Resource group.

Syntax

CREATE RESOURCE GROUP resource_group_name 
TO CLASSIFIER1, CLASSIFIER2, ...
WITH resource_limit

Parameters

  • resource_group_name: The name of the resource group to be created.

  • CLASSIFIER: Classifiers used to filter the queries on which resource limits are imposed. You must specify a classifier using "key"="value" pairs. You can set multiple classifiers for a resource group.

    Parameters for classifiers are listed below:

    ParameterRequiredDescription
    userNoThe name of user.
    roleNoThe role of user.
    query_typeNoThe type of query. SELECT and INSERT (from v2.5) are supported. When INSERT tasks hit a resource group with query_type as insert, the BE node reserves the specified CPU resources for the tasks.
    source_ipNoThe CIDR block from which the query is initiated.
    dbNoThe database which the query accesses. It can be specified by strings separated by commas (,).
  • resource_limit: Resource limits to be imposed on the resource group. You must specify resource limits using "key"="value" pairs. You can set multiple resource limits for a resource group.

    Parameters for resource limits are listed below:

    ParameterRequiredDescription
    cpu_core_limitNoThe soft limit for the number of CPU cores that can be allocated to the resource group on the BE. In actual business scenarios, CPU cores that are allocated to the resource group proportionally scale based on the availability of CPU cores on the BE. Valid values: any non-zero positive integer.
    mem_limitNoThe percentage of memory that can be used for queries in the total memory that is provided by the BE. Unit: %. Valid values: (0, 1).
    concurrency_limitNoThe upper limit of concurrent queries in a resource group. It is used to avoid system overload caused by too many concurrent queries.
    big_query_cpu_second_limitNoThe upper time limit of CPU occupation for a big query. Concurrent queries add up the time. The unit is second.
    big_query_scan_rows_limitNoThe upper limit of row counts that can be scanned by a big query.
    big_query_mem_limitNoThe upper limit of memory usage of a big query. The unit is byte.
    typeNoThe type of resource group. Valid values:
    short_query: When queries from the short_query resource group are running, the BE node reserves the CPU cores defined in short_query.cpu_core_limit. CPU cores for all normal resource groups are limited to "the total CPU cores - short_query.cpu_core_limit".
    normal: When no query from the short_query resource group is running, the CPU core limit above is not imposed on the normal resource groups.
    Note that you can create only ONE short_query resource group in a cluster.

Example

Example 1: Creates the resource group rg1 based on multiple classifiers.

CREATE RESOURCE GROUP rg1
TO
(user='rg1_user1', role='rg1_role1', query_type in ('select'), source_ip='192.168.x.x/24'),
(user='rg1_user2', query_type in ('select'), source_ip='192.168.x.x/24'),
(user='rg1_user3', source_ip='192.168.x.x/24'),
(user='rg1_user4'),
(db='db1')
WITH ('cpu_core_limit' = '10',
'mem_limit' = '20%',
'type' = 'normal',
'big_query_cpu_second_limit' = '100',
'big_query_scan_rows_limit' = '100000',
'big_query_mem_limit' = '1073741824'
);