TiDB Resource Group Settings

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: tidb资源组设置

| username: 心在飞翔

[TiDB Usage Environment] Production / Testing / PoC
[TiDB Version]
[Reproduction Path] What operations were performed when the issue occurred
[Encountered Issue: Issue Phenomenon and Impact]
[Resource Configuration] Go to TiDB Dashboard - Cluster Info - Hosts and take a screenshot of this page
[Attachments: Screenshots / Logs / Monitoring]

When creating a resource group, why can’t RU_PER_SEC be set to UNLIMITED, or how can it be set to UNLIMITED?
create RESOURCE GROUP rg1 RU_PER_SEC = 500 QUERY_LIMIT=(EXEC_ELAPSED=‘60s’, ACTION=KILL, WATCH=SIMILAR DURATION=‘10m’);

| username: 连连看db | Original post link

The default value of RU_PER_SEC is UNLIMITED, so you don’t need to create it yourself. If you don’t specify a resource group when creating, it will be bound to the default resource group by default, which is set to UNLIMITED.

| username: 心在飞翔 | Original post link

Actually, I want to achieve that RU_PER_SEC is not limited, but the execution time is limited. That is, QUERY_LIMIT=(EXEC_ELAPSED=‘60s’, ACTION=KILL, WATCH=SIMILAR DURATION=‘10m’);

| username: 心在飞翔 | Original post link

Creating a new resource group doesn’t seem to work, but modifying the default resource group can achieve the desired effect:

ALTER RESOURCE GROUP default QUERY_LIMIT=(EXEC_ELAPSED='60s', ACTION=KILL, WATCH=SIMILAR DURATION='10m');
default UNLIMITED MEDIUM YES EXEC_ELAPSED='1m0s', ACTION=KILL, WATCH=SIMILAR DURATION='10m0s'
| username: 有猫万事足 | Original post link

You can set a very large value for RU_PER_SEC, keeping everything else unchanged, and it will roughly have this effect.

Because the RU_PER_SEC you set is much greater than the RU your cluster can provide, it is equivalent to having no limit. The downside is that you might need to pay attention to this limit when scaling up.

| username: 心在飞翔 | Original post link

This method is feasible. After thinking it over carefully, if we classify the business into different levels and use different access users for different levels, then impose resource restrictions on the users, it would be difficult to implement in practice. It would be better to just cut it off directly and terminate any query that exceeds 10 seconds.