<@U0A71G31CDV> can I setup maximum concurrent quer...
# questions-and-troubleshooting
p
@Rocky can I setup maximum concurrent query and queue query per user level
r
Yes, you can set a maximum concurrent query limit and enable query queuing at the user level using Resource Groups. Starting from v3.1.4, StarRocks supports individual concurrency limits and queuing for each resource group. By creating a resource group with a "classifier" that matches a specific user, you effectively apply these limits to that user. How to set it up 1. Create a Resource Group for the User: Use the
CREATE RESOURCE GROUP
statement. You must define a
user
classifier and set the
concurrency_limit
.
Copy code
sql
    CREATE RESOURCE GROUP user_a_group
    TO
        (user='user_a') -- Matches queries from user_a
    WITH (
        "concurrency_limit" = "10",  -- Max 10 concurrent queries for this user
        "cpu_weight" = "10",
        "mem_limit" = "20%"
    );
2. How Queuing Works: When the number of concurrent queries from
user_a
exceeds the
concurrency_limit
(10 in the example above), any additional queries from that user will automatically be placed in a queue instead of failing. 3. Configure Global Queue Behavior (Optional): You can control how the queue behaves (e.g., how many queries can wait and for how long) using global session variables: * `query_queue_max_queued_queries`: The maximum number of queries that can be in the queue before new ones are rejected (default: 1024). * `query_queue_pending_timeout_second`: How long a query can wait in the queue before timing out (default: 300s). Key Version Details * v3.1.4 and later: Support for
concurrency_limit
within a resource group is fully optimized and managed by the Leader FE to ensure accurate queuing even during sudden traffic spikes. * Prior to v3.1.4: Resource groups were primarily used for CPU/Memory isolation. Global concurrency limits existed, but per-group queuing was less robust. Summary of Properties Property | Description
concurrency_limit
| The maximum number of concurrent queries allowed for the resource group (and thus the user).
user
(Classifier)
| Binds the resource group's limits to a specific StarRocks user. Referencessql-reference/sql-statements/cluster-management/resource_group/CREATE_RESOURCE_GROUP.mdadministration/management/resource_management/resource_group.md