starrocks_audit_db__.starrocks_audit_tbl__, administrators can instead adopt a data-driven approach to tuning resource groups. Key metrics such as CPU time, memory consumption, and query concurrency offer objective insights into actual workload characteristics.
This approach helps:
- Prevent query latency caused by resource contention
- Protect the cluster from resource exhaustion
- Improve overall stability and predictability
CPU Resource Allocation
Objective
Determine per-user CPU consumption and allocate CPU resources proportionally usingcpu_weight or exclusive_cpu_cores.
Analysis
The following SQL aggregates total CPU time per user (cpuCostNs) over the last 30 days, converts it to seconds, and calculates the percentage of total CPU usage.
Best Practices
Assume a fixed number of CPU cores per BE (for example, 64 cores). If a user accounts for 16% (cpu_usage_percentage) of total CPU time, allocating approximately 64 × 16% ≈ 11 cores is reasonable.
You can configure the CPU limits for the resource group as follows:
-
exclusive_cpu_cores:- Its value must not exceed the total number of cores on a single BE.
- The sum of
exclusive_cpu_coresof all resource groups must not exceed the total number of cores on a single BE.
-
cpu_weight:- Applies only to soft-isolation resource groups.
- Determines relative CPU share among competing queries on remaining cores.
- Does not map directly to a fixed number of CPU cores.
Memory Management
Objective
Identify memory-intensive users and define appropriate memory limits and circuit breakers.Analysis
The following SQL computes the maximum memory usage per user (memCostBytes) for a single query over the last 30 days.
Best Practices
max_mem_mb represents total memory usage across all BEs. You can calculate the approximate per-BE memory usage as: max_mem_mb / number_of_BEs.
You can configure the memory limits for the resource group as follows:
-
big_query_mem_limit:- Protects the cluster from anomalously large queries.
- You can set it to a relatively high threshold to avoid false-positive query termination.
-
mem_limit:- In most cases, set it to a high value (for example,
0.9).
- In most cases, set it to a high value (for example,
Concurrency Control
Objective
Identify peak query concurrency per user and define appropriateconcurrency_limit values.
Analysis
The following SQL analyzes per-minute query concurrency over the last 30 days and extracts the maximum observed concurrency per user.Best Practices
The above analysis is performed at minute granularity. Actual per-second concurrency may be higher. You can configure the concurrency limits for the resource group as follows:-
concurrency_limit- Set it to approximately 1.5× the observed peak to provide headroom.
- For users with extreme concurrency spikes, you can further enable Query Queues to smooth peak load and protect cluster stability.
Resource Isolation for Asynchronous Materialized Views
Objective
Prevent asynchronous materialized view refresh operations from impacting interactive queries.Analysis
The following SQL identifies memory-intensive materialized view refresh operations, typically characterized byINSERT OVERWRITE statements.
Best Practices
The database provides a system-defined resource group (default_mv_wg) for materialized view refresh tasks by default. However, customizing a dedicated resource group for materialized view refresh tasks is strongly recommended to enforce strict isolation and prevent materialized view refresh operations from degrading foreground query performance.
For instructions on configuring resource group limits, see Best Practice for CPU Resource Allocation and Best Practice for Memory Management.
The following example only provides guidance on creating and assign a dedicated resource group to materialized view refresh tasks.
-
Create a dedicated resource group for materialized view refresh:
-
Assign the resource group to a materialized view.
- Assign while creating a materialized view:
- Assign to an existing materialized view: