<@U0A71G31CDV> can starrock limit resource such as...
# questions-and-troubleshooting
l
@Rocky can starrock limit resource such as memory, cpu assigned to each user when run query? for example user1 was assinged 10% mem, cpu, user2 was asigned 20% mem, cpu?
r
Hi there! I'm Rocky. Yes, StarRocks can definitely limit resources like CPU and memory assigned to specific users or roles using a feature called Resource Groups (also known as Workload Management). By creating Resource Groups and using Classifiers, you can effectively isolate workloads and ensure that one user doesn't consume all the cluster's resources. How it works: 1. Define a Resource Group: You specify the resource limits (CPU, Memory, and Concurrency) for the group. 2. Use Classifiers: You map specific users or roles to that Resource Group. When that user runs a query, StarRocks automatically assigns it to the designated group. Example Configuration: If you want to assign 10% memory/CPU to
user1
and 20% to
user2
, you can follow this pattern: 1. Enable Resource Groups First, ensure the resource group feature is enabled (it is usually enabled by default in recent versions):
Copy code
sql
SET GLOBAL enable_resource_group = true;
2. Create Resource Groups for your users You can define limits using properties like
cpu_core_limit
and
mem_limit
.
Copy code
sql
-- Resource Group for user1 (10% target)
CREATE RESOURCE GROUP rg_user1
PROPERTIES (
    "cpu_core_limit" = "2", -- Example core limit
    "mem_limit" = "0.1",    -- 10% of the total BE memory
    "type" = "normal"
);

-- Resource Group for user2 (20% target)
CREATE RESOURCE GROUP rg_user2
PROPERTIES (
    "cpu_core_limit" = "4", -- Example core limit
    "mem_limit" = "0.2",    -- 20% of the total BE memory
    "type" = "normal"
);
3. Bind Users to the Groups (Classifiers) You use Classifiers to tell StarRocks which user belongs to which group:
Copy code
sql
-- Map user1 to rg_user1
ALTER RESOURCE GROUP rg_user1 ADD CLASSIFIER (user='user1');

-- Map user2 to rg_user2
ALTER RESOURCE GROUP rg_user2 ADD CLASSIFIER (user='user2');
Key Parameters: *
mem_limit
: The percentage of memory (from 0.0 to 1.0) that this group can use on each Backend (BE). *
cpu_core_limit
: The maximum number of CPU cores this group can use. *
concurrency_limit
: You can also limit the number of concurrent queries for that user to prevent system overload. This setup ensures that
user1
and
user2
stay within their allocated "lane," providing great multi-tenant stability! Let me know if you need help with the specific syntax for your version of StarRocks.
l
i think u are missing SQL Error [1193] [HY000]: Getting analyzing error. Detail message: Unknown system variable 'enable_resource_group', the most similar variables are {'enable_group_execution', 'enable_query_dump', 'enable_cross_join'}. Getting analyzing error. Detail message: Unknown system variable 'enable_resource_group', the most similar variables are {'enable_group_execution', 'enable_query_dump', 'enable_cross_join'}.
@Rocky SQL Error [1193] [HY000]: Getting analyzing error. Detail message: Unknown system variable 'enable_resource_group', the most similar variables are {'enable_group_execution', 'enable_query_dump', 'enable_cross_join'}. Getting analyzing error. Detail message: Unknown system variable 'enable_resource_group', the most similar variables are {'enable_group_execution', 'enable_query_dump', 'enable_cross_join'}.
r
Hello! I'm Rocky. It looks like you're encountering an error because the system variable
enable_resource_group
is not recognized by your StarRocks cluster. This error typically happens for one of two reasons related to the version of StarRocks you are using: 1. You are using StarRocks 3.0 or later Starting from StarRocks 3.0, the "Resource Group" feature was evolved and replaced by Workload Management (Workload Groups). The variable
enable_resource_group
is no longer used in these versions. * To enable Workload Management: Use the variable
enable_workload_group
instead.
Copy code
sql
    SET GLOBAL enable_workload_group = true;
* To specify a group for your session: Use the variable
workload_group
.
Copy code
sql
    SET workload_group = 'your_group_name';
2. You are using a version earlier than 2.2 The Resource Group feature was introduced in StarRocks v2.2. If you are on a very old version, this variable will not exist. ────────── Recommended Actions: 1. Check your StarRocks version: Run the following command to see which version you are running:
Copy code
sql
    SELECT VERSION();
2. Use Workload Groups (for v3.0+): If you are on version 3.x, I recommend looking into the Workload Group documentation. You can create a group like this:
Copy code
sql
    CREATE WORKLOAD GROUP IF NOT EXISTS big_query_group
    PROPERTIES (
        "cpu_share" = "10",
        "mem_limit" = "20%"
    );
Then assign your session to it:
Copy code
sql
    SET workload_group = 'big_query_group';
3. Check for typos: Ensure there isn't a small typo in the variable name, though the error message suggests it is completely missing from your current version's variable list. If you are trying to follow a specific tutorial or documentation, it might be for an older version of StarRocks. Let me know which version you are on, and I can give you the exact commands for that version!