From 896f94c4e6e8587308f3193a7635b37da70bf3c3 Mon Sep 17 00:00:00 2001 From: xixirangrang Date: Wed, 1 Feb 2023 15:29:59 +0800 Subject: [PATCH 01/63] updated 3 articles --- TOC.md | 2 + .../information-schema-processlist.md | 85 ++++++++++--------- .../information-schema-resource-groups.md | 70 +++++++++++++++ privilege-management.md | 12 +++ 4 files changed, 130 insertions(+), 39 deletions(-) create mode 100644 information-schema/information-schema-resource-groups.md diff --git a/TOC.md b/TOC.md index 9ac74ccbe7028..157a163045c89 100644 --- a/TOC.md +++ b/TOC.md @@ -645,6 +645,7 @@ - [`ALTER INDEX`](/sql-statements/sql-statement-alter-index.md) - [`ALTER INSTANCE`](/sql-statements/sql-statement-alter-instance.md) - [`ALTER PLACEMENT POLICY`](/sql-statements/sql-statement-alter-placement-policy.md) + - [`ALTER RESOURCE GROUP`](/sql-statements/sql-statement-alter-resource-group.md) - [`ALTER TABLE`](/sql-statements/sql-statement-alter-table.md) - [`ALTER TABLE COMPACT`](/sql-statements/sql-statement-alter-table-compact.md) - [`ALTER USER`](/sql-statements/sql-statement-alter-user.md) @@ -852,6 +853,7 @@ - [`PLACEMENT_POLICIES`](/information-schema/information-schema-placement-policies.md) - [`PROCESSLIST`](/information-schema/information-schema-processlist.md) - [`REFERENTIAL_CONSTRAINTS`](/information-schema/information-schema-referential-constraints.md) + - [`RESOURCE_GROUPS`](/information-schema/information-schema-resource-groups.md) - [`SCHEMATA`](/information-schema/information-schema-schemata.md) - [`SEQUENCES`](/information-schema/information-schema-sequences.md) - [`SESSION_VARIABLES`](/information-schema/information-schema-session-variables.md) diff --git a/information-schema/information-schema-processlist.md b/information-schema/information-schema-processlist.md index 2200c5944ecb7..934448b124026 100644 --- a/information-schema/information-schema-processlist.md +++ b/information-schema/information-schema-processlist.md @@ -12,7 +12,8 @@ The `PROCESSLIST` table has additional columns not present in `SHOW PROCESSLIST` * A `DIGEST` column to show the digest of the SQL statement. * A `MEM` column to show the memory used by the request that is being processed, in bytes. * A `DISK` column to show the disk usage in bytes. -* A `TxnStart` column to show the start time of the transaction +* A `TxnStart` column to show the start time of the transaction. +* A `RESOURCE_GROUP_NAME` column to show the resource group name. {{< copyable "sql" >}} @@ -21,24 +22,25 @@ USE information_schema; DESC processlist; ``` -``` -+----------+---------------------+------+------+---------+-------+ -| Field | Type | Null | Key | Default | Extra | -+----------+---------------------+------+------+---------+-------+ -| ID | bigint(21) unsigned | NO | | 0 | | -| USER | varchar(16) | NO | | | | -| HOST | varchar(64) | NO | | | | -| DB | varchar(64) | YES | | NULL | | -| COMMAND | varchar(16) | NO | | | | -| TIME | int(7) | NO | | 0 | | -| STATE | varchar(7) | YES | | NULL | | -| INFO | longtext | YES | | NULL | | -| DIGEST | varchar(64) | YES | | | | -| MEM | bigint(21) unsigned | YES | | NULL | | -| DISK | bigint(21) unsigned | YES | | NULL | | -| TxnStart | varchar(64) | NO | | | | -+----------+---------------------+------+------+---------+-------+ -12 rows in set (0.00 sec) +```sql ++---------------------+---------------------+------+------+---------+-------+ +| Field | Type | Null | Key | Default | Extra | ++---------------------+---------------------+------+------+---------+-------+ +| ID | bigint(21) unsigned | NO | | 0 | | +| USER | varchar(16) | NO | | | | +| HOST | varchar(64) | NO | | | | +| DB | varchar(64) | YES | | NULL | | +| COMMAND | varchar(16) | NO | | | | +| TIME | int(7) | NO | | 0 | | +| STATE | varchar(7) | YES | | NULL | | +| INFO | longtext | YES | | NULL | | +| DIGEST | varchar(64) | YES | | | | +| MEM | bigint(21) unsigned | YES | | NULL | | +| DISK | bigint(21) unsigned | YES | | NULL | | +| TxnStart | varchar(64) | NO | | | | +| RESOURCE_GROUP_NAME | varchar(32) | NO | | | | ++---------------------+---------------------+------+------+---------+-------+ +13 rows in set (0.00 sec) ``` {{< copyable "sql" >}} @@ -47,18 +49,21 @@ DESC processlist; SELECT * FROM processlist\G ``` -``` +```sql *************************** 1. row *************************** - ID: 16 - USER: root - HOST: 127.0.0.1 - DB: information_schema - COMMAND: Query - TIME: 0 - STATE: autocommit - INFO: SELECT * FROM processlist - MEM: 0 -TxnStart: + ID: 5794501045170209171 + USER: root + HOST: 127.0.0.1:60645 + DB: information_schema + COMMAND: Query + TIME: 0 + STATE: autocommit + INFO: SELECT * FROM processlist + DIGEST: dbfaa16980ec628011029f0aaf0d160f4b040885240dfc567bf760d96d374f7e + MEM: 0 + DISK: 0 + TxnStart: +RESOURCE_GROUP_NAME: default 1 row in set (0.00 sec) ``` @@ -76,6 +81,7 @@ Fields in the `PROCESSLIST` table are described as follows: * MEM: The memory used by the request that is being processed, in bytes. * DISK: The disk usage in bytes. * TxnStart: The start time of the transaction. +* RESOURCE_GROUP_NAME: The resource group name. ## CLUSTER_PROCESSLIST @@ -88,13 +94,14 @@ SELECT * FROM information_schema.cluster_processlist; ``` ```sql -+-----------------+-----+------+----------+------+---------+------+------------+------------------------------------------------------+-----+----------------------------------------+ -| INSTANCE | ID | USER | HOST | DB | COMMAND | TIME | STATE | INFO | MEM | TxnStart | -+-----------------+-----+------+----------+------+---------+------+------------+------------------------------------------------------+-----+----------------------------------------+ -| 10.0.1.22:10080 | 150 | u1 | 10.0.1.1 | test | Query | 0 | autocommit | select count(*) from usertable | 372 | 05-28 03:54:21.230(416976223923077223) | -| 10.0.1.22:10080 | 138 | root | 10.0.1.1 | test | Query | 0 | autocommit | SELECT * FROM information_schema.cluster_processlist | 0 | 05-28 03:54:21.230(416976223923077220) | -| 10.0.1.22:10080 | 151 | u1 | 10.0.1.1 | test | Query | 0 | autocommit | select count(*) from usertable | 372 | 05-28 03:54:21.230(416976223923077224) | -| 10.0.1.21:10080 | 15 | u2 | 10.0.1.1 | test | Query | 0 | autocommit | select max(field0) from usertable | 496 | 05-28 03:54:21.230(416976223923077222) | -| 10.0.1.21:10080 | 14 | u2 | 10.0.1.1 | test | Query | 0 | autocommit | select max(field0) from usertable | 496 | 05-28 03:54:21.230(416976223923077225) | -+-----------------+-----+------+----------+------+---------+------+------------+------------------------------------------------------+-----+----------------------------------------+ ++-----------------+-----+------+----------+------+---------+------+------------+------------------------------------------------------+-----+----------------------------------------+---------------------+ +| INSTANCE | ID | USER | HOST | DB | COMMAND | TIME | STATE | INFO | MEM | TxnStart | RESOURCE_GROUP_NAME | ++-----------------+-----+------+----------+------+---------+------+------------+------------------------------------------------------+-----+----------------------------------------+---------------------+ + +| 10.0.1.22:10080 | 150 | u1 | 10.0.1.1 | test | Query | 0 | autocommit | select count(*) from usertable | 372 | 05-28 03:54:21.230(416976223923077223) | default | +| 10.0.1.22:10080 | 138 | root | 10.0.1.1 | test | Query | 0 | autocommit | SELECT * FROM information_schema.cluster_processlist | 0 | 05-28 03:54:21.230(416976223923077220) | rg1 | +| 10.0.1.22:10080 | 151 | u1 | 10.0.1.1 | test | Query | 0 | autocommit | select count(*) from usertable | 372 | 05-28 03:54:21.230(416976223923077224) | rg2 | +| 10.0.1.21:10080 | 15 | u2 | 10.0.1.1 | test | Query | 0 | autocommit | select max(field0) from usertable | 496 | 05-28 03:54:21.230(416976223923077222) | default | +| 10.0.1.21:10080 | 14 | u2 | 10.0.1.1 | test | Query | 0 | autocommit | select max(field0) from usertable | 496 | 05-28 03:54:21.230(416976223923077225) | default | ++-----------------+-----+------+----------+------+---------+------+------------+------------------------------------------------------+-----+----------------------------------------+---------------------+ ``` diff --git a/information-schema/information-schema-resource-groups.md b/information-schema/information-schema-resource-groups.md new file mode 100644 index 0000000000000..9cc11c6a33a84 --- /dev/null +++ b/information-schema/information-schema-resource-groups.md @@ -0,0 +1,70 @@ +--- +title: RESOURCE_GROUPS +summary: Learn the `RESOURCE_GROUPS` information_schema table. +--- + +The `RESOURCE_GROUPS` table shows information about all resource groups. See [Resource Conctrol in TiDB](/tidb-resource-control.md). + +```sql +USE information_schema; +DESC resource_groups; +``` + +```sql ++-----------------+-------------+------+------+---------+-------+ +| Field | Type | Null | Key | Default | Extra | ++-----------------+-------------+------+------+---------+-------+ +| NAME | varchar(32) | NO | | NULL | | +| MODE | varchar(12) | NO | | NULL | | +| RRU | bigint(21) | YES | | NULL | | +| RRU_TOKEN | bigint(21) | YES | | NULL | | +| WRU | bigint(21) | YES | | NULL | | +| WRU_TOKEN | bigint(21) | YES | | NULL | | +| CPU | bigint(21) | YES | | NULL | | +| READ_BANDWIDTH | bigint(21) | YES | | NULL | | +| WRITE_BANDWIDTH | bigint(21) | YES | | NULL | | ++-----------------+-------------+------+------+---------+-------+ +9 rows in set (0.08 sec) +``` + +## Examples + +{{< copyable "sql" >}} + +```sql +mysql> CREATE RESOURCE GROUP rg1 RRU_PER_SEC=1000 WRU_PER_SEC=2000 ; -- Use RU_MODE to create the resource group rg1 +Query OK, 0 rows affected (0.34 sec) +mysql> SHOW CREATE RESOURCE GROUP rg1; -- Displays the definition of the rg1 resource group. ++----------------+------------------------------------------------------------------+ +| Resource_Group | Create Resource Group | ++----------------+------------------------------------------------------------------+ +| rg1 | CREATE RESOURCE GROUP `rg1` RRU_PER_SEC=1000 WRU_PER_SEC=2000 | ++----------------+------------------------------------------------------------------+ +1 row in set (0.00 sec) +mysql> SELECT * FROM information_schema.placement_policies WHERE NAME = 'rg1'; -- Displays the runtime status of the resource group rg1. ++--------+---------+------+-----------+------+-----------+------+----------------+-----------------+ +| NAME | MODE | RRU | RRU_TOKEN | WRU | WRU_TOKEN | CPU | READ_BANDWIDTH | WRITE_BANDWIDTH | ++--------+---------+------+-----------+------+-----------+------+----------------+-----------------+ +| rg1 | RU_MODE | 1000 | 168999 | 2000 | 249999 | NULL | NULL | NULL | ++--------+---------+------+-----------+------+-----------+------+----------------+-----------------+ +1 row in set (0.02 sec) +``` + +```sql +mysql> CREATE RESOURCE GROUP rg2 CPU="8" IO_READ_BANDWIDTH="1000Mi" IO_WRITE_BANDWIDTH="1000Mi"; -- Use RAW_MODE to create the resource group rg2 +Query OK, 0 rows affected (0.20 sec) +mysql> show create resource group rg2; -- Displays the definition of the rg2 resource group. ++----------------+-----------------------------------------------------------------------------------------------+ +| Resource_Group | Create Resource Group | ++----------------+-----------------------------------------------------------------------------------------------+ +| rg2 | CREATE RESOURCE GROUP `rg2` CPU="8" IO_READ_BANDWIDTH="1000Mi" IO_WRITE_BANDWIDTH="1000Mi" | ++----------------+-----------------------------------------------------------------------------------------------+ +1 row in set (0.00 sec) +mysql> SELECT * FROM information_schema.resource_groups WHERE NAME = 'rg2'; -- Displays the runtime status of the resource group rg2. ++--------+----------+------+-----------+------+-----------+------+----------------+-----------------+ +| NAME | MODE | RRU | RRU_TOKEN | WRU | WRU_TOKEN | CPU | READ_BANDWIDTH | WRITE_BANDWIDTH | ++--------+----------+------+-----------+------+-----------+------+----------------+-----------------+ +| rg2 | RAW_MODE | NULL | NULL | NULL | NULL | 8000 | 1048576000 | 1048576000 | ++--------+----------+------+-----------+------+-----------+------+----------------+-----------------+ +1 row in set (0.00 sec) +``` diff --git a/privilege-management.md b/privilege-management.md index 0d62cc731af05..d7adedb933bf8 100644 --- a/privilege-management.md +++ b/privilege-management.md @@ -364,6 +364,18 @@ Requires `SUPER` privilege. Requires `SUPER` or `CONNECTION_ADMIN` privilege to kill other user sessions. +### CREATE RESOURCE GROUP + +Requires `SUPER` or `RESOURCE_GROUP_ADMIN` privilege. + +### ALTER RESOURCE GROUP + +Requires `SUPER` or `RESOURCE_GROUP_ADMIN` privilege. + +### DROP RESOURCE GROUP + +Requires `SUPER` or `RESOURCE_GROUP_ADMIN` privilege. + ## Implementation of the privilege system ### Privilege table From 7e7d291904a8dba7d2c1f1ed43f454d8308a2218 Mon Sep 17 00:00:00 2001 From: xixirangrang Date: Wed, 1 Feb 2023 15:52:24 +0800 Subject: [PATCH 02/63] Create sql-statement-alter-resource-group.md --- .../sql-statement-alter-resource-group.md | 92 +++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 sql-statements/sql-statement-alter-resource-group.md diff --git a/sql-statements/sql-statement-alter-resource-group.md b/sql-statements/sql-statement-alter-resource-group.md new file mode 100644 index 0000000000000..4ea13893c7c43 --- /dev/null +++ b/sql-statements/sql-statement-alter-resource-group.md @@ -0,0 +1,92 @@ +--- +title: ALTER RESOURCE GROUP +summary: Learn the usage of ALTER RESOURCE GROUP in TiDB. +--- + +# ALTER RESOURCE GROUP + +The `ALTER RESOURCE GROUP` statement is used to modify the resource group in a database. + +## Synopsis + +```ebnf+diagram +AlterResourceGroupStmt: + "ALTER" "RESOURCE" "GROUP" IfNotExists ResourceGroupName ResourceGroupOptionList BurstableOption + +IfNotExists ::= + ('IF' 'NOT' 'EXISTS')? + +ResourceGroupName: + Identifier + +ResourceGroupOptionList: + DirectResourceGroupOption +| ResourceGroupOptionList DirectResourceGroupOption +| ResourceGroupOptionList ',' DirectResourceGroupOption + +DirectResourceGroupOption: + "RRU_PER_SEC" EqOpt stringLit +| "WRU_PER_SEC" EqOpt stringLit + +BurstableOption ::= + ("BURSTABLE")? + +``` + +TiDB supports the following `DirectResourceGroupOption`, where [RU (Resource Unit)](/tidb-RU.md) is TiDB's unified abstraction unit for CPU, IO, and other system resources. + +| Parameter | Description | Example | +|---------------|-------------------------------------|------------------------| +|`RRU_PER_SEC` | Quota of RU read per second |`RRU_PER_SEC = 500` | +|`WRU_PER_SEC` | Quota of RU write per second |`WRU_PER_SEC = 300` | + +If the `BURSTABLE` attribute is set, the corresponding resource group allows the system resources to be used exceeding the quota if the system resources are sufficient. + +> **Note:** +> +> The `ALTER RESOURCE GROUP` statement can only be executed when the global variable [`tidb_enable_resource_group`](/system-variables.md#tidb_enable_resource_control-new-in-v660) is set to `ON`. + +## Examples + +Create a resource group named `rg1` and modify its properties. + +```sql +mysql> DROP RESOURCE GROUP IF EXISTS rg1; +Query OK, 0 rows affected (0.22 sec) +mysql> CREATE RESOURCE GROUP IF NOT EXISTS rg1 + -> RRU_PER_SEC = 500 + -> WRU_PER_SEC = 300 + -> BURSTABLE + -> ; +Query OK, 0 rows affected (0.08 sec) +mysql> SELECT * FROM information_schema.resource_groups WHERE NAME ='rg1'; ++------+--------------+---------------------------------------------------------------+ +| Name | Plan_type | Directive | ++------+--------------+---------------------------------------------------------------+ +| rg1 | tenancy | {"RRU_PER_SEC": 500, "WRU_PER_SEC": 300, "BURSTABLE": true} | ++------+--------------+---------------------------------------------------------------+ +1 row in set (0.00 sec) + +mysql> ALTER RESOURCE GROUP IF NOT EXISTS rg1 + -> RRU_PER_SEC = 600 + -> WRU_PER_SEC = 400 + -> ; +Query OK, 0 rows affected (0.09 sec) +mysql> SELECT * FROM information_schema.resource_groups WHERE NAME ='rg1'; ++------+--------------+---------------------------------------------------------------+ +| Name | Plan_type | Directive | ++------+--------------+---------------------------------------------------------------+ +| rg1 | tenancy | {"RRU_PER_SEC": 600, "WRU_PER_SEC": 400, "BURSTABLE": false} | ++------+--------------+---------------------------------------------------------------+ +1 row in set (0.00 sec) +``` + +## MySQL compatibility + +MySQL also supports [ALTER RESOURCE GROUP](https://dev.mysql.com/doc/refman/8.0/en/alter-resource-group.html). However, the accepted parameters are different from TiDB so that they are not compatible. + +## See also + +* [DROP RESOURCE GROUP](/sql-statements/sql-statement-drop-resource-group.md) +* [CREATE RESOURCE GROUP](/sql-statements/sql-statement-create-resource-group.md) +* [RU](/tidb-RU.md) From 8c6f68e7ffb69226aace25864eecf738b94dd062 Mon Sep 17 00:00:00 2001 From: xixirangrang Date: Wed, 1 Feb 2023 18:11:05 +0800 Subject: [PATCH 03/63] Update sql-statement-alter-user.md --- sql-statements/sql-statement-alter-user.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/sql-statements/sql-statement-alter-user.md b/sql-statements/sql-statement-alter-user.md index c437c2de633d5..18ef49ada0b92 100644 --- a/sql-statements/sql-statement-alter-user.md +++ b/sql-statements/sql-statement-alter-user.md @@ -12,7 +12,7 @@ This statement changes an existing user inside the TiDB privilege system. In the ```ebnf+diagram AlterUserStmt ::= - 'ALTER' 'USER' IfExists (UserSpecList RequireClauseOpt ConnectionOptions PasswordOption LockOption AttributeOption | 'USER' '(' ')' 'IDENTIFIED' 'BY' AuthString) + 'ALTER' 'USER' IfExists (UserSpecList RequireClauseOpt ConnectionOptions PasswordOption LockOption AttributeOption | 'USER' '(' ')' 'IDENTIFIED' 'BY' AuthString) ResourceGroupNameOption UserSpecList ::= UserSpec ( ',' UserSpec )* @@ -31,6 +31,8 @@ PasswordOption ::= ( 'PASSWORD' 'EXPIRE' ( 'DEFAULT' | 'NEVER' | 'INTERVAL' N 'D LockOption ::= ( 'ACCOUNT' 'LOCK' | 'ACCOUNT' 'UNLOCK' )? AttributeOption ::= ( 'COMMENT' CommentString | 'ATTRIBUTE' AttributeString )? + +ResourceGroupNameOption::= ( 'RESOURCE' 'GROUP' Identifier)? ``` ## Examples @@ -135,6 +137,16 @@ ALTER USER 'newuser' PASSWORD REUSE INTERVAL 90 DAY; Query OK, 0 rows affected (0.02 sec) ``` +Use `ALTER USER ... RESOURCE GROUP` to modify the resource group of the user `newuser` to `rg1`. + +```sql +ALTER USER 'newuser' RESOURCE GROUP rg1; +``` + +``` +Query OK, 0 rows affected (0.02 sec) +``` + ## See also From 910f132f8e3f001927545310c78db2f82ca5c878 Mon Sep 17 00:00:00 2001 From: xixirangrang Date: Wed, 1 Feb 2023 18:20:14 +0800 Subject: [PATCH 04/63] added CREATE RESOURCE GROUP --- TOC.md | 1 + .../sql-statement-create-resource-group.md | 81 +++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 sql-statements/sql-statement-create-resource-group.md diff --git a/TOC.md b/TOC.md index 157a163045c89..6f7f7bc565b53 100644 --- a/TOC.md +++ b/TOC.md @@ -661,6 +661,7 @@ - [`CREATE DATABASE`](/sql-statements/sql-statement-create-database.md) - [`CREATE INDEX`](/sql-statements/sql-statement-create-index.md) - [`CREATE PLACEMENT POLICY`](/sql-statements/sql-statement-create-placement-policy.md) + - [`CREATE RESOURCE GROUP`](/sql-statements/sql-statement-create-resource-group.md) - [`CREATE ROLE`](/sql-statements/sql-statement-create-role.md) - [`CREATE SEQUENCE`](/sql-statements/sql-statement-create-sequence.md) - [`CREATE TABLE LIKE`](/sql-statements/sql-statement-create-table-like.md) diff --git a/sql-statements/sql-statement-create-resource-group.md b/sql-statements/sql-statement-create-resource-group.md new file mode 100644 index 0000000000000..f6e1c9df64bf3 --- /dev/null +++ b/sql-statements/sql-statement-create-resource-group.md @@ -0,0 +1,81 @@ +--- +title: CREATE RESOURCE GROUP +summary: Learn the usage of CREATE RESOURCE GROUP in TiDB. +--- + +# CREATE RESOURCE GROUP + +You can run the `CREATE RESOURCE GROUP` statement to create a resource group in the currently selected database. + +## Synopsis + +```ebnf+diagram +CreateResourceGroupStmt: + "CREATE" "RESOURCE" "GROUP" IfNotExists ResourceGroupName ResourceGroupOptionList BurstableOption + +IfNotExists ::= + ('IF' 'NOT' 'EXISTS')? + +ResourceGroupName: + Identifier + +ResourceGroupOptionList: + DirectResourceGroupOption +| ResourceGroupOptionList DirectResourceGroupOption +| ResourceGroupOptionList ',' DirectResourceGroupOption + +DirectResourceGroupOption: + "RRU_PER_SEC" EqOpt stringLit +| "WRU_PER_SEC" EqOpt stringLit + +BurstableOption ::= + ("BURSTABLE")? + +``` + +The `ResourceGroupName` of a resource group is globally unique and cannot be duplicated. + +TiDB supports the following `DirectResourceGroupOption`, where [RU (Resource Unit)](/tidb-RU.md) is TiDB's unified abstraction unit for CPU, IO, and other system resources. + +| Parameter | Description | Example | +|---------------|-------------------------------------|------------------------| +|`RRU_PER_SEC` | Quota of RU read per second |`RRU_PER_SEC = 500` | +|`WRU_PER_SEC` | Quota of RU write per second |`WRU_PER_SEC = 300` | + +If the `BURSTABLE` attribute is set, the corresponding resource group allows the system resources to be used exceeding the quota if the system resources are sufficient. + +> **Note:** +> +> The `CREATE RESOURCE GROUP` statement can only be executed when the global variable [`tidb_enable_resource_group`](/system-variables.md#tidb_enable_resource_control-new-in-v660) is set to `ON`. + +## Examples + +Create a resource group named `rg1`. + +```sql +mysql> DROP RESOURCE GROUP IF EXISTS rg1; +Query OK, 0 rows affected (0.22 sec) +mysql> CREATE RESOURCE GROUP IF NOT EXISTS rg1 + -> RRU_PER_SEC = 500 + -> WRU_PER_SEC = 300 + -> BURSTABLE + -> ; +Query OK, 0 rows affected (0.08 sec) +mysql> SELECT * FROM information_schema.resource_groups WHERE NAME ='rg1'; ++------+--------------+---------------------------------------------------------------+ +| Name | Plan_type | Directive | ++------+--------------+---------------------------------------------------------------+ +| rg1 | tenancy | {"RRU_PER_SEC": 5000, "WRU_PER_SEC": 1000, "BURSTABLE": true} | ++------+--------------+---------------------------------------------------------------+ +1 row in set (0.00 sec) +``` + +## MySQL compatibility + +MySQL also supports [CREATE RESOURCE GROUP](https://dev.mysql.com/doc/refman/8.0/en/create-resource-group.html). However, the accepted parameters are different from TiDB so that they are not compatible. + +## See also + +* [DROP RESOURCE GROUP](/sql-statements/sql-statement-drop-resource-group.md) +* [ALTER RESOURCE GROUP](/sql-statements/sql-statement-alter-resource-group.md) +* [RU](/tidb-RU.md) From 722bd3004b6abf5b124a2257244ef3eed0829e2b Mon Sep 17 00:00:00 2001 From: xixirangrang Date: Wed, 1 Feb 2023 18:45:14 +0800 Subject: [PATCH 05/63] translate 6 more docs --- TOC.md | 2 + .../sql-statement-create-resource-group.md | 2 +- sql-statements/sql-statement-create-user.md | 20 +++- .../sql-statement-drop-resource-group.md | 66 +++++++++++++ ...ql-statement-show-create-resource-group.md | 46 +++++++++ .../sql-statement-show-privileges.md | 93 +++++++++++-------- system-variables.md | 13 +++ 7 files changed, 202 insertions(+), 40 deletions(-) create mode 100644 sql-statements/sql-statement-drop-resource-group.md create mode 100644 sql-statements/sql-statement-show-create-resource-group.md diff --git a/TOC.md b/TOC.md index 6f7f7bc565b53..55d4af92a304d 100644 --- a/TOC.md +++ b/TOC.md @@ -678,6 +678,7 @@ - [`DROP DATABASE`](/sql-statements/sql-statement-drop-database.md) - [`DROP INDEX`](/sql-statements/sql-statement-drop-index.md) - [`DROP PLACEMENT POLICY`](/sql-statements/sql-statement-drop-placement-policy.md) + - [`DROP RESOURCE GROUP`](/sql-statements/sql-statement-drop-resource-group.md) - [`DROP ROLE`](/sql-statements/sql-statement-drop-role.md) - [`DROP SEQUENCE`](/sql-statements/sql-statement-drop-sequence.md) - [`DROP STATS`](/sql-statements/sql-statement-drop-stats.md) @@ -729,6 +730,7 @@ - [`SHOW CONFIG`](/sql-statements/sql-statement-show-config.md) - [`SHOW CREATE DATABASE`](/sql-statements/sql-statement-show-create-database.md) - [`SHOW CREATE PLACEMENT POLICY`](/sql-statements/sql-statement-show-create-placement-policy.md) + - [`SHOW CREATE RESOURCE GROUP`](/sql-statements/sql-statement-show-create-resource-group.md) - [`SHOW CREATE SEQUENCE`](/sql-statements/sql-statement-show-create-sequence.md) - [`SHOW CREATE TABLE`](/sql-statements/sql-statement-show-create-table.md) - [`SHOW CREATE USER`](/sql-statements/sql-statement-show-create-user.md) diff --git a/sql-statements/sql-statement-create-resource-group.md b/sql-statements/sql-statement-create-resource-group.md index f6e1c9df64bf3..e9bb21b3910ff 100644 --- a/sql-statements/sql-statement-create-resource-group.md +++ b/sql-statements/sql-statement-create-resource-group.md @@ -5,7 +5,7 @@ summary: Learn the usage of CREATE RESOURCE GROUP in TiDB. # CREATE RESOURCE GROUP -You can run the `CREATE RESOURCE GROUP` statement to create a resource group in the currently selected database. +You can use the `CREATE RESOURCE GROUP` statement to create a resource group in the currently selected database. ## Synopsis diff --git a/sql-statements/sql-statement-create-user.md b/sql-statements/sql-statement-create-user.md index c6f96317adc78..2b373e844a1af 100644 --- a/sql-statements/sql-statement-create-user.md +++ b/sql-statements/sql-statement-create-user.md @@ -12,7 +12,7 @@ This statement creates a new user, specified with a password. In the MySQL privi ```ebnf+diagram CreateUserStmt ::= - 'CREATE' 'USER' IfNotExists UserSpecList RequireClauseOpt ConnectionOptions PasswordOption LockOption AttributeOption + 'CREATE' 'USER' IfNotExists UserSpecList RequireClauseOpt ConnectionOptions PasswordOption LockOption AttributeOption ResourceGroupNameOption IfNotExists ::= ('IF' 'NOT' 'EXISTS')? @@ -35,6 +35,8 @@ PasswordOption ::= ( 'PASSWORD' 'EXPIRE' ( 'DEFAULT' | 'NEVER' | 'INTERVAL' N 'D LockOption ::= ( 'ACCOUNT' 'LOCK' | 'ACCOUNT' 'UNLOCK' )? AttributeOption ::= ( 'COMMENT' CommentString | 'ATTRIBUTE' AttributeString )? + +ResourceGroupNameOption::= ( 'RESOURCE' 'GROUP' Identifier)? ``` ## Examples @@ -129,6 +131,22 @@ CREATE USER 'newuser9'@'%' PASSWORD EXPIRE; Query OK, 1 row affected (0.02 sec) ``` +Create a user that uses the resource group `rg1`. + +```sql +CREATE USER 'newuser7'@'%' RESOURCE GROUP rg1; +SELECT USER, HOST, USER_ATTRIBUTES FROM MYSQL.USER WHERE USER='newuser7'; +``` + +```sql ++-----------+------+---------------------------------------------------+ +| USER | HOST | ATTRIBUTE | ++-----------+------+---------------------------------------------------+ +| newuser7 | % | {"resource_group": "rg1"} | ++-----------+------+---------------------------------------------------+ +1 rows in set (0.00 sec) +``` + ## MySQL compatibility The following `CREATE USER` options are not yet supported by TiDB, and will be parsed but ignored: diff --git a/sql-statements/sql-statement-drop-resource-group.md b/sql-statements/sql-statement-drop-resource-group.md new file mode 100644 index 0000000000000..9c68334564084 --- /dev/null +++ b/sql-statements/sql-statement-drop-resource-group.md @@ -0,0 +1,66 @@ +--- +title: DROP RESOURCE GROUP +summary: Learn the usage of DROP RESOURCE GROUP in TiDB. +--- + +# DROP RESOURCE GROUP + +You can use the `DROP RESOURCE GROUP` statement to drop a resource group in the currently selected database. + +## Synopsis + +```ebnf+diagram +DropResourceGroupStmt: + "DROP" "RESOURCE" "GROUP" IfNotExists ResourceGroupName + +IfNotExists ::= + ('IF' 'NOT' 'EXISTS')? + +ResourceGroupName: + Identifier +``` + +> **Note:** +> +> The `DROP RESOURCE GROUP` statement can only be executed when the global variable [`tidb_enable_resource_group`](/system-variables.md#tidb_enable_resource_control-new-in-v660) is set to `ON`. + +## Examples + +Drop a resource group named `rg1`. + +```sql +mysql> DROP RESOURCE GROUP IF EXISTS rg1; +Query OK, 0 rows affected (0.22 sec) +mysql> CREATE RESOURCE GROUP IF NOT EXISTS rg1 ( + -> RRU_PER_SEC = 500 + -> WRU_PER_SEC = 300 + -> BURSTABLE + -> ); +Query OK, 0 rows affected (0.08 sec) +mysql> SELECT * FROM information_schema.resource_groups WHERE NAME ='rg1'; ++------+--------------+---------------------------------------------------------------+ +| Name | Plan_type | Directive | ++------+--------------+---------------------------------------------------------------+ +| rg1 | tenancy | {"RRU_PER_SEC": 500, "WRU_PER_SEC": 300, "BURSTABLE": true} | ++------+--------------+---------------------------------------------------------------+ +1 row in set (0.00 sec) + +mysql> DROP RESOURCE GROUP IF NOT EXISTS rg1 ; +Query OK, 1 rows affected (0.09 sec) +mysql> SELECT * FROM information_schema.resource_groups WHERE NAME ='rg1'; ++------+--------------+---------------------------------------------------------------+ +| Name | Plan_type | Directive | ++------+--------------+---------------------------------------------------------------+ ++------+--------------+---------------------------------------------------------------+ +0 row in set (0.00 sec) +``` + +## MySQL compatibility + +MySQL also supports [DROP RESOURCE GROUP](https://dev.mysql.com/doc/refman/8.0/en/drop-resource-group.html), but TiDB does not support the `FORCE` parameter. + +## See also + +* [ALTER RESOURCE GROUP](/sql-statements/sql-statement-alter-resource-group.md) +* [CREATE RESOURCE GROUP](/sql-statements/sql-statement-create-resource-group.md) +* [RU](/tidb-RU.md) \ No newline at end of file diff --git a/sql-statements/sql-statement-show-create-resource-group.md b/sql-statements/sql-statement-show-create-resource-group.md new file mode 100644 index 0000000000000..feacae4360619 --- /dev/null +++ b/sql-statements/sql-statement-show-create-resource-group.md @@ -0,0 +1,46 @@ +--- +title: SHOW CREATE RESOURCE GROUP +summary: Learn the usage of SHOW CREATE RESOURCE GROUP in TiDB. +--- + +# SHOW CREATE RESOURCE GROUP + +You can use the `SHOW CREATE RESOURCE GROUP` statement to view the current definition of a resource group, and recreate it in another TiDB cluster. + +## Synopsis + +```ebnf+diagram +ShowCreateResourceGroupStmt ::= + "SHOW" "CREATE" "RESOURCE" "GROUP" ResourceGroupName + +ResourceGroupName ::= + Identifier +``` + +## Examples + +View the current definition of the resource group `rg1` and recreate it in another TiDB cluster. + +```sql +CREATE RESOURCE GROUP rg1 RRU_PER_SEC=100 WRU_PER_SEC=200; +Query OK, 0 rows affected (0.10 sec) +``` + +```sql +SHOW CREATE RESOURCE GROUP rg1; +***************************[ 1. row ]*************************** +Resource_Group | rg1 +Create Resource Group | CREATE RESOURCE GROUP `rg1` RRU_PER_SEC=100 WRU_PER_SEC=200 +1 row in set (0.00 sec) +``` + +## MySQL compatibility + +This statement is a TiDB extension for MySQL. + +## See also + +* [TiDB RESOURCE CONTROL](/tidb-resource-control.md) +* [CREATE RESOURCE GROUP](/sql-statements/sql-statement-alter-resource-group.md) +* [ALTER RESOURCE GROUP](/sql-statements/sql-statement-alter-resource-group.md) +* [DROP RESOURCE GROUP](/sql-statements/sql-statement-drop-resource-group.md) diff --git a/sql-statements/sql-statement-show-privileges.md b/sql-statements/sql-statement-show-privileges.md index 83abfc6d52c3c..0b640608eb756 100644 --- a/sql-statements/sql-statement-show-privileges.md +++ b/sql-statements/sql-statement-show-privileges.md @@ -16,45 +16,62 @@ This statement shows a list of assignable privileges in TiDB. It is a static lis ## Examples -```sql +``` mysql> show privileges; -+-------------------------+---------------------------------------+-------------------------------------------------------+ -| Privilege | Context | Comment | -+-------------------------+---------------------------------------+-------------------------------------------------------+ -| Alter | Tables | To alter the table | -| Alter | Tables | To alter the table | -| Alter routine | Functions,Procedures | To alter or drop stored functions/procedures | -| Create | Databases,Tables,Indexes | To create new databases and tables | -| Create routine | Databases | To use CREATE FUNCTION/PROCEDURE | -| Create temporary tables | Databases | To use CREATE TEMPORARY TABLE | -| Create view | Tables | To create new views | -| Create user | Server Admin | To create new users | -| Delete | Tables | To delete existing rows | -| Drop | Databases,Tables | To drop databases, tables, and views | -| Event | Server Admin | To create, alter, drop and execute events | -| Execute | Functions,Procedures | To execute stored routines | -| File | File access on server | To read and write files on the server | -| Grant option | Databases,Tables,Functions,Procedures | To give to other users those privileges you possess | -| Index | Tables | To create or drop indexes | -| Insert | Tables | To insert data into tables | -| Lock tables | Databases | To use LOCK TABLES (together with SELECT privilege) | -| Process | Server Admin | To view the plain text of currently executing queries | -| Proxy | Server Admin | To make proxy user possible | -| References | Databases,Tables | To have references on tables | -| Reload | Server Admin | To reload or refresh tables, logs and privileges | -| Replication client | Server Admin | To ask where the slave or master servers are | -| Replication slave | Server Admin | To read binary log events from the master | -| Select | Tables | To retrieve rows from table | -| Show databases | Server Admin | To see all databases with SHOW DATABASES | -| Show view | Tables | To see views with SHOW CREATE VIEW | -| Shutdown | Server Admin | To shut down the server | -| Super | Server Admin | To use KILL thread, SET GLOBAL, CHANGE MASTER, etc. | -| Trigger | Tables | To use triggers | -| Create tablespace | Server Admin | To create/alter/drop tablespaces | -| Update | Tables | To update existing rows | -| Usage | Server Admin | No privileges - allow connect only | -+-------------------------+---------------------------------------+-------------------------------------------------------+ -32 rows in set (0.00 sec) ++---------------------------------+---------------------------------------+-------------------------------------------------------+ +| Privilege | Context | Comment | ++---------------------------------+---------------------------------------+-------------------------------------------------------+ +| Alter | Tables | To alter the table | +| Alter routine | Functions,Procedures | To alter or drop stored functions/procedures | +| Config | Server Admin | To use SHOW CONFIG and SET CONFIG statements | +| Create | Databases,Tables,Indexes | To create new databases and tables | +| Create routine | Databases | To use CREATE FUNCTION/PROCEDURE | +| Create role | Server Admin | To create new roles | +| Create temporary tables | Databases | To use CREATE TEMPORARY TABLE | +| Create view | Tables | To create new views | +| Create user | Server Admin | To create new users | +| Delete | Tables | To delete existing rows | +| Drop | Databases,Tables | To drop databases, tables, and views | +| Drop role | Server Admin | To drop roles | +| Event | Server Admin | To create, alter, drop and execute events | +| Execute | Functions,Procedures | To execute stored routines | +| File | File access on server | To read and write files on the server | +| Grant option | Databases,Tables,Functions,Procedures | To give to other users those privileges you possess | +| Index | Tables | To create or drop indexes | +| Insert | Tables | To insert data into tables | +| Lock tables | Databases | To use LOCK TABLES (together with SELECT privilege) | +| Process | Server Admin | To view the plain text of currently executing queries | +| Proxy | Server Admin | To make proxy user possible | +| References | Databases,Tables | To have references on tables | +| Reload | Server Admin | To reload or refresh tables, logs and privileges | +| Replication client | Server Admin | To ask where the slave or master servers are | +| Replication slave | Server Admin | To read binary log events from the master | +| Select | Tables | To retrieve rows from table | +| Show databases | Server Admin | To see all databases with SHOW DATABASES | +| Show view | Tables | To see views with SHOW CREATE VIEW | +| Shutdown | Server Admin | To shut down the server | +| Super | Server Admin | To use KILL thread, SET GLOBAL, CHANGE MASTER, etc. | +| Trigger | Tables | To use triggers | +| Create tablespace | Server Admin | To create/alter/drop tablespaces | +| Update | Tables | To update existing rows | +| Usage | Server Admin | No privileges - allow connect only | +| BACKUP_ADMIN | Server Admin | | +| RESTORE_ADMIN | Server Admin | | +| SYSTEM_USER | Server Admin | | +| SYSTEM_VARIABLES_ADMIN | Server Admin | | +| ROLE_ADMIN | Server Admin | | +| CONNECTION_ADMIN | Server Admin | | +| PLACEMENT_ADMIN | Server Admin | | +| DASHBOARD_CLIENT | Server Admin | | +| RESTRICTED_TABLES_ADMIN | Server Admin | | +| RESTRICTED_STATUS_ADMIN | Server Admin | | +| RESTRICTED_VARIABLES_ADMIN | Server Admin | | +| RESTRICTED_USER_ADMIN | Server Admin | | +| RESTRICTED_CONNECTION_ADMIN | Server Admin | | +| RESTRICTED_REPLICA_WRITER_ADMIN | Server Admin | | +| RESOURCE_GROUP_ADMIN | Server Admin | | ++---------------------------------+---------------------------------------+-------------------------------------------------------+ +49 rows in set (0.00 sec) ``` ## MySQL compatibility diff --git a/system-variables.md b/system-variables.md index 6a9034a86cd8e..e1691f2a7e887 100644 --- a/system-variables.md +++ b/system-variables.md @@ -1799,6 +1799,19 @@ MPP is a distributed computing framework provided by the TiFlash engine, which a +### `tidb_enable_resource_control` New in v6.6.0 + +> **Warning:** +> +> This feature is experimental and its form and usage may change in subsequent versions. + +- Scope: GLOBAL +- Persists to cluster: Yes +- Default value: `OFF` +- Type: Boolean +- This variable is a switch for [the resource control feature](/tidb-resource-control.md). When this variable is set to `ON`, the cluster supports resource isolation of applications by resource group. + + ### tidb_enable_reuse_chunk New in v6.4.0 - Scope: SESSION | GLOBAL From 72d5153230fe9a4852f34b0196a974bae0a877bd Mon Sep 17 00:00:00 2001 From: xixirangrang Date: Wed, 1 Feb 2023 21:53:51 +0800 Subject: [PATCH 06/63] add part of resource control doc --- TOC.md | 1 + tidb-resource-control.md | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 tidb-resource-control.md diff --git a/TOC.md b/TOC.md index 55d4af92a304d..2c21e0512216f 100644 --- a/TOC.md +++ b/TOC.md @@ -159,6 +159,7 @@ - [Back up and Restore Data Using Dumpling and TiDB Lightning](/backup-and-restore-using-dumpling-lightning.md) - [Back Up and Restore RawKV](/br/rawkv-backup-and-restore.md) - [Incremental Backup and Restore](/br/br-incremental-guide.md) + - [Resource Control](/tidb-resource-control.md) - [Configure Time Zone](/configure-time-zone.md) - [Daily Checklist](/daily-check.md) - [Maintain TiFlash](/tiflash/maintain-tiflash.md) diff --git a/tidb-resource-control.md b/tidb-resource-control.md new file mode 100644 index 0000000000000..a2bb9db5bc156 --- /dev/null +++ b/tidb-resource-control.md @@ -0,0 +1,38 @@ +--- +title: Use Resource Control to Achieve Resource Isolation +summary: Learn how to use resource management to control and schedule application resource consumption. +--- + +# Use Resource Control to Achieve Resource Isolation + +> **Warning:** +> +> This feature is experimental and its form and usage may change in subsequent versions. + +Using the resource control feature, as a cluster administrator, you can define resource groups and limit the read and write quotas by resource groups. After you bind users to a resource group, the TiDB layer will perform flow control on the user's read and write requests according to the read and write quotas set by the bound resource group. Meanwile, the TiKV layer will schedule the requests according to the priority of the read and write quota mapping. Through flow control and scheduling, you can achieve resource isolation of your applications and meet the quality of service (QoS) requirements. + +The introduction of the resource control feature is a milestone for TiDB. It can divide a distributed database cluster into multiple logical units. Even if an individual unit overuses resources, it does not crowd out the resources needed by other units. + +This feature applies to the following scenarios: + +- You can combine multiple small and medium-sized applications from different systems into one TiDB cluster. If the load of an individual application grows larger, it does not affect the normal operation of other businesses. When the system load is low, busy applications can still be allocated the required system resources even if they exceed the set read and write quotas, so as to achieve the maximum utilization of resources. +- You can choose to combine all test environments into a single cluster, or group the batch tasks that consume more resources into a single resource group. It can improve hardware utilization and reduce operating costs while ensuring that critical applications receive the necessary resources. + +In addition, the rational use of the resource control feature can reduce the number of clusters, ease the difficulty of operation and maintenance, and save management costs. + +## Parameters for resource control + +The resource control feature introduces two new global variables. + +* TiDB: you can use the system variable [`tidb_enable_resource_control`](/system-variables.md#tidb-tidb_enable_resource_control) to control whether to enable flow control for a resource group. +* TiKV: you can use the parameter [`resource_control.enabled`](/tikv-configuration-file.md#resource_control) to control whether to use request scheduling based on resource group quotas. Note that this parameter does not support dynamic modification. You need to restart the TiKV instance to for the modification to take effect. + +The results of the combination of these two parameters are shown in the following table. + +| `resource_control.enabled` | `tidb_enable_resource_control`= ON | `tidb_enable_resource_control`= OFF | +|:----------------------------|:-------------------------------------|:-------------------------------------| +| `resource_control.enabled`= true | Flow control and scheduling (recommended) | Invalid combination | +| `resource_control.enabled`= false | Only flow control | The feature is disabled. | + +## How to use resource control + From 5647598510612f8c2de1360cfb5f0e04bd8740dd Mon Sep 17 00:00:00 2001 From: xixirangrang Date: Thu, 2 Feb 2023 10:44:57 +0800 Subject: [PATCH 07/63] finish translation except ru.md --- ...ql-statement-show-create-resource-group.md | 2 +- tidb-resource-control.md | 102 +++++++++++++++++- tikv-configuration-file.md | 9 ++ 3 files changed, 111 insertions(+), 2 deletions(-) diff --git a/sql-statements/sql-statement-show-create-resource-group.md b/sql-statements/sql-statement-show-create-resource-group.md index feacae4360619..a0e293a481468 100644 --- a/sql-statements/sql-statement-show-create-resource-group.md +++ b/sql-statements/sql-statement-show-create-resource-group.md @@ -5,7 +5,7 @@ summary: Learn the usage of SHOW CREATE RESOURCE GROUP in TiDB. # SHOW CREATE RESOURCE GROUP -You can use the `SHOW CREATE RESOURCE GROUP` statement to view the current definition of a resource group, and recreate it in another TiDB cluster. +You can use the `SHOW CREATE RESOURCE GROUP` statement to view the current definition of a resource group. ## Synopsis diff --git a/tidb-resource-control.md b/tidb-resource-control.md index a2bb9db5bc156..3921699c75917 100644 --- a/tidb-resource-control.md +++ b/tidb-resource-control.md @@ -20,12 +20,28 @@ This feature applies to the following scenarios: In addition, the rational use of the resource control feature can reduce the number of clusters, ease the difficulty of operation and maintenance, and save management costs. + + +> **Note:** +> +> This feature does not support [Serverless Tier clusters](/tidb-cloud/select-cluster-tier.md#serverless-tier-beta). + + + ## Parameters for resource control The resource control feature introduces two new global variables. * TiDB: you can use the system variable [`tidb_enable_resource_control`](/system-variables.md#tidb-tidb_enable_resource_control) to control whether to enable flow control for a resource group. -* TiKV: you can use the parameter [`resource_control.enabled`](/tikv-configuration-file.md#resource_control) to control whether to use request scheduling based on resource group quotas. Note that this parameter does not support dynamic modification. You need to restart the TiKV instance to for the modification to take effect. +* TiKV: you can use the parameter [`resource_control.enabled`](/tikv-configuration-file.md#resource_control) to control whether to use request scheduling based on resource group quotas. + + + +> **Note:** +> +> The parameter `resource_control.enabled` is disabled by default. It does not support dynamic modification. You need to contact the [PingCAP support team](/tidb-cloud/tidb-cloud-support.md) to enable it. You need to restart the TiKV instance for the modification to take effect. + + The results of the combination of these two parameters are shown in the following table. @@ -36,3 +52,87 @@ The results of the combination of these two parameters are shown in the followin ## How to use resource control +For an existing resource group, you can modify the read and write quota of the resource group by using [`ALTER RESOURCE GROUP`](/sql-statements/sql-statement-alter-resource-group.md). The quota changes to the resource group take effect immediately. + +You can delete a resource group by using [`DROP RESOURCE GROUP`](/sql-statements/sql-statement-drop-resource-group.md). The user bound by the deleted resource group will use the `default` resource group for resource isolation. + +> **Note:** +> +> - When you bind a user resource group with `CREATE USER` or `ALTER USER`, it will not take effect for the user's existing sessions, but only for the user's new sessions. +> - The `default` resource group does not have quota restrictions for bound user applications. It is recommended to create the `default` resource group by using [`CREATE RESOURCE GROUP`](/sql-statements/sql-statement-create-resource-group.md), or modify the quota for the `default` resource group by using [`ALTER RESOURCE GROUP`](/sql-statements/sql-statement-alter-resource-group.md) to control the quota for the `default` resource group. + +### Prerequisites + +To create, modify, or delete a resource group, you need to have the `SUPER` or `RESOURCE_GROUP_ADMIN` privilege. + +You can create a resource group in the cluster with [`CREATE RESOURCE GROUP`](/sql-statements/sql-statement-create-resource-group.md), and then bind the users to a specific resource group by using [`CREATE USER`](/sql-statements/ sql-statement-create-user.md) or [`ALTER USER`](/sql-statements/sql-statement-alter-user.md). + +### Step 1. Enable the resource control feature + +Enable flow control for the resource group. + +```sql +SET GLOBAL tidb_enable_resource_control = 'ON'; +``` + +In TiKV, set the parameter `resource_control.enabled` to `true`. The parameter `resource_control.enabled` is disabled by default. You need to contact the [PingCAP support team](/tidb-cloud/tidb-cloud-support.md) to enable it. + +### Step 2. Create a resource group, and bind users to it + +Resource group quotas are expressed as [RU (Resource Unit)](/tidb-RU.md), which is TiDB's unified abstraction of CPU, IO, and other system resources. + +The following is an example of how to create a resource group and bind users to it. + +1. Create a resource group `rg1` with a quota of 500 RU per second for read requests and 300 RU per second for write requests, and allow applications in this resource group to use excessive resources when system resources are available. + + ```sql + CREATE RESOURCE GROUP IF NOT EXISTS rg1 + RRU_PER_SEC = 500 + WRU_PER_SEC = 300 + BURSTABLE + ; + ``` + +2. Create a resource group `rg2` with a quota of 600 RU per second for read requests and 400 RU per second for write requests, and do not allow applications in this resource group to use excessive resources even when system resources are available. + + ```sql + CREATE RESOURCE GROUP IF NOT EXISTS rg2 + RRU_PER_SEC = 600 + WRU_PER_SEC = 400 + ; + ``` + +3. Bind users `usr1` and `usr2` to resource groups `rg1` and `rg2` respectively. + + ```sql + ALTER USER usr1 RESOURCE GROUP rg1; + ``` + + ```sql + ALTER USER usr2 RESOURCE GROUP rg2; + ``` + +After you complete the preceeding operations, the resource consumption by newly created sessions is controlled by the specified quota. Read requests are limited by the quota of the read RU, and write requests are limited by the quota of the write RU. If the system load is relatively high and there is no spare capacity, the resource consumption rate of both users will be strictly controlled not to exceed the quota. Meanwhile, the consumption ratio of RU metrics for both users' read and write requests is basically proportional to the specified quota. When system resources are abundant, the resource consumption rate of `usr1` is allowed to exceed the quota because it has set `BURSTABLE`. + +## Monitoring and charts + +TiDB regularly collects runtime information about resource control and provides visual charts of the metrics in Grafana's **TiDB** > **Resource Control** panel. The metrics are detailed in the **Resource Control** section of [TiDB Important Monitoring Metrics](/grafana-tidb-dashboard.md). + +## Tool Compatibility + +The resource control feature is not compatible with data export/import and replication tools including BR, TiDB Lightning, and TiCDC. + +## Limitations + +Currently, the resource control feature has the following limitations: + +* This feature only supports restriction and scheduling of read and write requests initiated by frontend clients. It does not support restriction and scheduling of background tasks such as `DDL` and `Auto Analyze`. +* Resource control will incur additional scheduling overhead. Therefore, there might be a slight performance degradation when this feature is enabled. + +## See also + +* [CREATE RESOURCE GROUP](/sql-statements/sql-statement-create-resource-group.md) +* [ALTER RESOURCE GROUP](/sql-statements/sql-statement-alter-resource-group.md) +* [DROP RESOURCE GROUP](/sql-statements/sql-statement-drop-resource-group.md) +* [RESOURCE GROUP RFC](https://docs.google.com/document/d/1sV5EVv8Cdpc6aBCDihc2akpE0iuantPf/) +* [RU](/tidb-RU.md) diff --git a/tikv-configuration-file.md b/tikv-configuration-file.md index 5ec47696b683a..4477efa95e39a 100644 --- a/tikv-configuration-file.md +++ b/tikv-configuration-file.md @@ -2155,3 +2155,12 @@ To reduce write latency, TiKV periodically fetches and caches a batch of timesta + The maximum number of TSOs in a timestamp request. + In a default TSO physical time update interval (`50ms`), PD provides at most 262144 TSOs. When requested TSOs exceed this number, PD provides no more TSOs. This configuration item is used to avoid exhausting TSOs and the reverse impact of TSO exhaustion on other businesses. If you increase the value of this configuration item to improve high availability, you need to decrease the value of [`tso-update-physical-interval`](/pd-configuration-file.md#tso-update-physical-interval) at the same time to get enough TSOs. + Default value: `8192` + +## resource_control + +Configuration items related to resource control. + +### `enabled` New in v6.6.0 + ++ Control whether to use read/write request scheduling based on resource group quotas. ++ Default value: `false`, which means to disable scheduling based on resource group quotas. \ No newline at end of file From 477496303e9be46ec124f5d6fa0bf2ef257e91fe Mon Sep 17 00:00:00 2001 From: xixirangrang Date: Thu, 2 Feb 2023 11:32:07 +0800 Subject: [PATCH 08/63] removed blank line --- sql-statements/sql-statement-show-create-resource-group.md | 2 +- system-variables.md | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/sql-statements/sql-statement-show-create-resource-group.md b/sql-statements/sql-statement-show-create-resource-group.md index a0e293a481468..031622acbbe0e 100644 --- a/sql-statements/sql-statement-show-create-resource-group.md +++ b/sql-statements/sql-statement-show-create-resource-group.md @@ -19,7 +19,7 @@ ResourceGroupName ::= ## Examples -View the current definition of the resource group `rg1` and recreate it in another TiDB cluster. +View the current definition of the resource group `rg1`. ```sql CREATE RESOURCE GROUP rg1 RRU_PER_SEC=100 WRU_PER_SEC=200; diff --git a/system-variables.md b/system-variables.md index e1691f2a7e887..31117125688aa 100644 --- a/system-variables.md +++ b/system-variables.md @@ -1811,7 +1811,6 @@ MPP is a distributed computing framework provided by the TiFlash engine, which a - Type: Boolean - This variable is a switch for [the resource control feature](/tidb-resource-control.md). When this variable is set to `ON`, the cluster supports resource isolation of applications by resource group. - ### tidb_enable_reuse_chunk New in v6.4.0 - Scope: SESSION | GLOBAL From 1971ca229da9c2e6c9dd1e032e28ed2fae701254 Mon Sep 17 00:00:00 2001 From: xixirangrang Date: Thu, 2 Feb 2023 13:57:42 +0800 Subject: [PATCH 09/63] Apply suggestions from code review --- .../information-schema-resource-groups.md | 2 +- .../sql-statement-alter-resource-group.md | 6 ++--- .../sql-statement-create-resource-group.md | 2 +- tidb-resource-control.md | 23 +++++++++++-------- 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/information-schema/information-schema-resource-groups.md b/information-schema/information-schema-resource-groups.md index 9cc11c6a33a84..30de61f760f3f 100644 --- a/information-schema/information-schema-resource-groups.md +++ b/information-schema/information-schema-resource-groups.md @@ -3,7 +3,7 @@ title: RESOURCE_GROUPS summary: Learn the `RESOURCE_GROUPS` information_schema table. --- -The `RESOURCE_GROUPS` table shows information about all resource groups. See [Resource Conctrol in TiDB](/tidb-resource-control.md). +The `RESOURCE_GROUPS` table shows information about all resource groups. See [Use Resource Control to Achieve Resource Isolation](/tidb-resource-control.md). ```sql USE information_schema; diff --git a/sql-statements/sql-statement-alter-resource-group.md b/sql-statements/sql-statement-alter-resource-group.md index 4ea13893c7c43..2fa605e889c2b 100644 --- a/sql-statements/sql-statement-alter-resource-group.md +++ b/sql-statements/sql-statement-alter-resource-group.md @@ -35,10 +35,10 @@ BurstableOption ::= TiDB supports the following `DirectResourceGroupOption`, where [RU (Resource Unit)](/tidb-RU.md) is TiDB's unified abstraction unit for CPU, IO, and other system resources. -| Parameter | Description | Example | +| Option | Description | Example | |---------------|-------------------------------------|------------------------| -|`RRU_PER_SEC` | Quota of RU read per second |`RRU_PER_SEC = 500` | -|`WRU_PER_SEC` | Quota of RU write per second |`WRU_PER_SEC = 300` | +|`RRU_PER_SEC` | Quota of read RU per second |`RRU_PER_SEC = 500` | +|`WRU_PER_SEC` | Quota of write RU per second |`WRU_PER_SEC = 300` | If the `BURSTABLE` attribute is set, the corresponding resource group allows the system resources to be used exceeding the quota if the system resources are sufficient. diff --git a/sql-statements/sql-statement-create-resource-group.md b/sql-statements/sql-statement-create-resource-group.md index e9bb21b3910ff..54c19fc09f0b1 100644 --- a/sql-statements/sql-statement-create-resource-group.md +++ b/sql-statements/sql-statement-create-resource-group.md @@ -65,7 +65,7 @@ mysql> SELECT * FROM information_schema.resource_groups WHERE NAME ='rg1'; +------+--------------+---------------------------------------------------------------+ | Name | Plan_type | Directive | +------+--------------+---------------------------------------------------------------+ -| rg1 | tenancy | {"RRU_PER_SEC": 5000, "WRU_PER_SEC": 1000, "BURSTABLE": true} | +| rg1 | tenancy | {"RRU_PER_SEC": 500, "WRU_PER_SEC": 300, "BURSTABLE": true} | +------+--------------+---------------------------------------------------------------+ 1 row in set (0.00 sec) ``` diff --git a/tidb-resource-control.md b/tidb-resource-control.md index 3921699c75917..4875e2a7cdccf 100644 --- a/tidb-resource-control.md +++ b/tidb-resource-control.md @@ -16,7 +16,7 @@ The introduction of the resource control feature is a milestone for TiDB. It can This feature applies to the following scenarios: - You can combine multiple small and medium-sized applications from different systems into one TiDB cluster. If the load of an individual application grows larger, it does not affect the normal operation of other businesses. When the system load is low, busy applications can still be allocated the required system resources even if they exceed the set read and write quotas, so as to achieve the maximum utilization of resources. -- You can choose to combine all test environments into a single cluster, or group the batch tasks that consume more resources into a single resource group. It can improve hardware utilization and reduce operating costs while ensuring that critical applications receive the necessary resources. +- You can choose to combine all test environments into a single cluster, or group the batch tasks that consume more resources into a single resource group. It can improve hardware utilization and reduce operating costs while ensuring that critical applications can still get the necessary resources. In addition, the rational use of the resource control feature can reduce the number of clusters, ease the difficulty of operation and maintenance, and save management costs. @@ -43,7 +43,7 @@ The resource control feature introduces two new global variables. -The results of the combination of these two parameters are shown in the following table. +The results of the combinations of these two parameters are shown in the following table. | `resource_control.enabled` | `tidb_enable_resource_control`= ON | `tidb_enable_resource_control`= OFF | |:----------------------------|:-------------------------------------|:-------------------------------------| @@ -54,18 +54,18 @@ The results of the combination of these two parameters are shown in the followin For an existing resource group, you can modify the read and write quota of the resource group by using [`ALTER RESOURCE GROUP`](/sql-statements/sql-statement-alter-resource-group.md). The quota changes to the resource group take effect immediately. -You can delete a resource group by using [`DROP RESOURCE GROUP`](/sql-statements/sql-statement-drop-resource-group.md). The user bound by the deleted resource group will use the `default` resource group for resource isolation. +You can delete a resource group by using [`DROP RESOURCE GROUP`](/sql-statements/sql-statement-drop-resource-group.md). The user bound to the deleted resource group will use the `default` resource group for resource isolation. > **Note:** > -> - When you bind a user resource group with `CREATE USER` or `ALTER USER`, it will not take effect for the user's existing sessions, but only for the user's new sessions. -> - The `default` resource group does not have quota restrictions for bound user applications. It is recommended to create the `default` resource group by using [`CREATE RESOURCE GROUP`](/sql-statements/sql-statement-create-resource-group.md), or modify the quota for the `default` resource group by using [`ALTER RESOURCE GROUP`](/sql-statements/sql-statement-alter-resource-group.md) to control the quota for the `default` resource group. +> - When you bind a user to a resource group by using `CREATE USER` or `ALTER USER`, it will not take effect for the user's existing sessions, but only for the user's new sessions. +> - The `default` resource group does not have quota restrictions for the user's applications. It is recommended to create the `default` resource group by using [`CREATE RESOURCE GROUP`](/sql-statements/sql-statement-create-resource-group.md), or modify the quota for the `default` resource group by using [`ALTER RESOURCE GROUP`](/sql-statements/sql-statement-alter-resource-group.md) to control the quota for the `default` resource group. ### Prerequisites To create, modify, or delete a resource group, you need to have the `SUPER` or `RESOURCE_GROUP_ADMIN` privilege. -You can create a resource group in the cluster with [`CREATE RESOURCE GROUP`](/sql-statements/sql-statement-create-resource-group.md), and then bind the users to a specific resource group by using [`CREATE USER`](/sql-statements/ sql-statement-create-user.md) or [`ALTER USER`](/sql-statements/sql-statement-alter-user.md). +You can create a resource group in the cluster by using [`CREATE RESOURCE GROUP`](/sql-statements/sql-statement-create-resource-group.md), and then bind the users to a specific resource group by using [`CREATE USER`](/sql-statements/ sql-statement-create-user.md) or [`ALTER USER`](/sql-statements/sql-statement-alter-user.md). ### Step 1. Enable the resource control feature @@ -75,9 +75,14 @@ Enable flow control for the resource group. SET GLOBAL tidb_enable_resource_control = 'ON'; ``` + + + In TiKV, set the parameter `resource_control.enabled` to `true`. The parameter `resource_control.enabled` is disabled by default. You need to contact the [PingCAP support team](/tidb-cloud/tidb-cloud-support.md) to enable it. -### Step 2. Create a resource group, and bind users to it + + +### Step 2. Create a resource group, and then bind users to it Resource group quotas are expressed as [RU (Resource Unit)](/tidb-RU.md), which is TiDB's unified abstraction of CPU, IO, and other system resources. @@ -112,7 +117,7 @@ The following is an example of how to create a resource group and bind users to ALTER USER usr2 RESOURCE GROUP rg2; ``` -After you complete the preceeding operations, the resource consumption by newly created sessions is controlled by the specified quota. Read requests are limited by the quota of the read RU, and write requests are limited by the quota of the write RU. If the system load is relatively high and there is no spare capacity, the resource consumption rate of both users will be strictly controlled not to exceed the quota. Meanwhile, the consumption ratio of RU metrics for both users' read and write requests is basically proportional to the specified quota. When system resources are abundant, the resource consumption rate of `usr1` is allowed to exceed the quota because it has set `BURSTABLE`. +After you complete the preceeding operations, the resource consumption by newly created sessions is controlled by the specified quota. Read requests are limited by the read RU quota, and write requests are limited by the write RU quota. If the system load is relatively high and there is no spare capacity, the resource consumption rate of both users will be strictly controlled not to exceed the quota. Meanwhile, the consumption ratio of RU metrics for both users' read and write requests is basically proportional to the specified quota. When system resources are abundant, the resource consumption rate of `usr1` is allowed to exceed the quota because it has set `BURSTABLE`, while `usr2` is not allowed. ## Monitoring and charts @@ -127,7 +132,7 @@ The resource control feature is not compatible with data export/import and repli Currently, the resource control feature has the following limitations: * This feature only supports restriction and scheduling of read and write requests initiated by frontend clients. It does not support restriction and scheduling of background tasks such as `DDL` and `Auto Analyze`. -* Resource control will incur additional scheduling overhead. Therefore, there might be a slight performance degradation when this feature is enabled. +* Resource control incurs additional scheduling overhead. Therefore, there might be a slight performance degradation when this feature is enabled. ## See also From 25f240857f74c4575c088f442071b5ad356b60a1 Mon Sep 17 00:00:00 2001 From: xixirangrang Date: Thu, 2 Feb 2023 14:04:22 +0800 Subject: [PATCH 10/63] Update tidb-resource-control.md --- tidb-resource-control.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tidb-resource-control.md b/tidb-resource-control.md index 4875e2a7cdccf..48c0c6b4ca64a 100644 --- a/tidb-resource-control.md +++ b/tidb-resource-control.md @@ -9,7 +9,7 @@ summary: Learn how to use resource management to control and schedule applicatio > > This feature is experimental and its form and usage may change in subsequent versions. -Using the resource control feature, as a cluster administrator, you can define resource groups and limit the read and write quotas by resource groups. After you bind users to a resource group, the TiDB layer will perform flow control on the user's read and write requests according to the read and write quotas set by the bound resource group. Meanwile, the TiKV layer will schedule the requests according to the priority of the read and write quota mapping. Through flow control and scheduling, you can achieve resource isolation of your applications and meet the quality of service (QoS) requirements. +Using the resource control feature, as a cluster administrator, you can define resource groups and limit the read and write quotas by resource groups. After you bind users to a resource group, the TiDB layer will perform flow control on the user's read and write requests according to the read and write quotas set by the bound resource group. Meanwhile, the TiKV layer will schedule the requests according to the priority of the read and write quota mapping. Through flow control and scheduling, you can achieve resource isolation of your applications and meet the quality of service (QoS) requirements. The introduction of the resource control feature is a milestone for TiDB. It can divide a distributed database cluster into multiple logical units. Even if an individual unit overuses resources, it does not crowd out the resources needed by other units. From 4d59f3bc6c3c3bf54cc838b49f5be712c6fe6815 Mon Sep 17 00:00:00 2001 From: xixirangrang Date: Thu, 2 Feb 2023 14:05:47 +0800 Subject: [PATCH 11/63] Update tidb-resource-control.md --- tidb-resource-control.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tidb-resource-control.md b/tidb-resource-control.md index 48c0c6b4ca64a..605e92d87557c 100644 --- a/tidb-resource-control.md +++ b/tidb-resource-control.md @@ -117,7 +117,7 @@ The following is an example of how to create a resource group and bind users to ALTER USER usr2 RESOURCE GROUP rg2; ``` -After you complete the preceeding operations, the resource consumption by newly created sessions is controlled by the specified quota. Read requests are limited by the read RU quota, and write requests are limited by the write RU quota. If the system load is relatively high and there is no spare capacity, the resource consumption rate of both users will be strictly controlled not to exceed the quota. Meanwhile, the consumption ratio of RU metrics for both users' read and write requests is basically proportional to the specified quota. When system resources are abundant, the resource consumption rate of `usr1` is allowed to exceed the quota because it has set `BURSTABLE`, while `usr2` is not allowed. +After you complete the preceding operations, the resource consumption by newly created sessions is controlled by the specified quota. Read requests are limited by the read RU quota, and write requests are limited by the write RU quota. If the system load is relatively high and there is no spare capacity, the resource consumption rate of both users will be strictly controlled not to exceed the quota. Meanwhile, the consumption ratio of RU metrics for both users' read and write requests is basically proportional to the specified quota. When system resources are abundant, the resource consumption rate of `usr1` is allowed to exceed the quota because it has set `BURSTABLE`, while `usr2` is not allowed. ## Monitoring and charts From 589edfbc501b6d51059aafd4294007c6b1a45277 Mon Sep 17 00:00:00 2001 From: xixirangrang Date: Thu, 2 Feb 2023 14:18:46 +0800 Subject: [PATCH 12/63] Apply suggestions from code review --- sql-statements/sql-statement-create-resource-group.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql-statements/sql-statement-create-resource-group.md b/sql-statements/sql-statement-create-resource-group.md index 54c19fc09f0b1..ff3ee76fb4197 100644 --- a/sql-statements/sql-statement-create-resource-group.md +++ b/sql-statements/sql-statement-create-resource-group.md @@ -33,11 +33,11 @@ BurstableOption ::= ``` -The `ResourceGroupName` of a resource group is globally unique and cannot be duplicated. +The resource group name parameter (`ResourceGroupName`) is globally unique and cannot be duplicated. TiDB supports the following `DirectResourceGroupOption`, where [RU (Resource Unit)](/tidb-RU.md) is TiDB's unified abstraction unit for CPU, IO, and other system resources. -| Parameter | Description | Example | +| Option | Description | Example | |---------------|-------------------------------------|------------------------| |`RRU_PER_SEC` | Quota of RU read per second |`RRU_PER_SEC = 500` | |`WRU_PER_SEC` | Quota of RU write per second |`WRU_PER_SEC = 300` | From d48a5d6c18932b5be6d2f8a0514ebe8119dc6bfb Mon Sep 17 00:00:00 2001 From: xixirangrang <35301108+hfxsd@users.noreply.github.com> Date: Fri, 3 Feb 2023 16:49:48 +0800 Subject: [PATCH 13/63] draft done --- grafana-resource-control-dashboard.md | 36 +++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 grafana-resource-control-dashboard.md diff --git a/grafana-resource-control-dashboard.md b/grafana-resource-control-dashboard.md new file mode 100644 index 0000000000000..ccc663f999f91 --- /dev/null +++ b/grafana-resource-control-dashboard.md @@ -0,0 +1,36 @@ +--- +title: Key Monitoring Metrics of Resource Control +summary: Learn some key metrics displayed on the Grafana Resource Control dashboard. +--- + +# Key Monitoring Metrics of Resource Control + +If you use TiUP to deploy the TiDB cluster, the monitoring system (Prometheus & Grafana) is deployed at the same time. For more information, see [Overview of the Monitoring Framework](/tidb-monitoring-framework.md). + +The Grafana dashboard is divided into a series of sub dashboards which include Overview, PD, TiDB, TiKV, Node\_exporter, Disk Performance, and Performance\_overview. A lot of metrics are there to help you diagnose. + +You can get an overview of the resource control status from the PD dashboard, where the key metrics are displayed. This document provides a detailed description of these key metrics. + +The following is the description of Resource Control Dashboard metrics items. + +## Resource Unit + +- RU: the [Resource Unit](/tidb-RU.md) consumption information of each Resource Group is calculated in real time. `total` is the sum of the Request Units consumed by all Resource Groups. The Request Unit consumption of each Resource Group should be equal to the sum of its read consumption (Read Request Unit) and write consumption (Write Request Unit). +- RU Per Query: the average number of Request Units consumed by each SQL statement per second is obtained by dividing the above Request Unit by the number of SQL statements executed per second. +- RRU: the Read Request Unit consumption information of each Resource Group is calculated in real time. `total` is the sum of the Read Request Units consumed by all Resource Groups. +- RRU Per Query: the average number of Read Request Units consumed by each SQL statement per second is obtained by dividing the above Read Request Unit by the number of SQL statements executed per second. +- WRU: the Write Request Unit consumption information of each Resource Group is calculated in real time. `total` is the sum of the Write Request Units consumed by all Resource Groups. +- WRU Per Query: the average number of Write Request Units consumed by each SQL statement per second is obtained by dividing the above Write Request Unit by the number of SQL statements executed per second. + +## Resource + +- KV Request Count: the number of KV requests is calculated in real time for each Resource Group. They are divided into read and write types. `total` is the sum of the KV requests involved by all Resource Groups. +- KV Request Count Per Query: the average number of read and write KV requests by each SQL statement per second is obtained by dividing the above KV Request Count by the number of SQL statements executed per second. +- Bytes Read: the amount of data read is calculated in real time for each Resource Group. `total` is the sum of the data read by all Resource Groups. +- Bytes Read Per Query: the average amount of data read by each SQL statement per second is obtained by dividing the above Bytes Read by the number of SQL statements executed per second. +- Bytes Written: the amount of data written is calculated in real time for each Resource Group. `total` is the sum of the data written by all Resource Groups. +- Bytes Written Per Query: the average amount of data written by each SQL statement per second is obtained by dividing the above Bytes Written by the number of SQL statements executed per second. +- KV CPU Time: the KV layer CPU time consumed is calculated in real time for each Resource Group. `total` is the sum of the KV layer CPU time consumed by all Resource Groups. +- KV CPU Time Per Query: the average KV layer CPU time consumed by each SQL statement per second is obtained by dividing the above KV CPU Time by the number of SQL statements executed per second. +- SQL CPU Time: the SQL layer CPU time consumed is calculated in real time for each Resource Group. `total` is the sum of the SQL layer CPU time consumed by all Resource Groups. +- SQL CPU Time Per Query: the average SQL layer CPU time consumed by each SQL statement per second is obtained by dividing the above SQL CPU Time by the number of SQL statements executed per second. From 53822c45981a9e98ee305bab045f7f9a1f207079 Mon Sep 17 00:00:00 2001 From: xixirangrang <35301108+hfxsd@users.noreply.github.com> Date: Fri, 3 Feb 2023 16:55:30 +0800 Subject: [PATCH 14/63] Update tidb-resource-control.md --- tidb-resource-control.md | 1 - 1 file changed, 1 deletion(-) diff --git a/tidb-resource-control.md b/tidb-resource-control.md index 605e92d87557c..87efa1311d84c 100644 --- a/tidb-resource-control.md +++ b/tidb-resource-control.md @@ -75,7 +75,6 @@ Enable flow control for the resource group. SET GLOBAL tidb_enable_resource_control = 'ON'; ``` - In TiKV, set the parameter `resource_control.enabled` to `true`. The parameter `resource_control.enabled` is disabled by default. You need to contact the [PingCAP support team](/tidb-cloud/tidb-cloud-support.md) to enable it. From e405d6eaa7f9322bb66c03992a6e843cb26e4dce Mon Sep 17 00:00:00 2001 From: xixirangrang <35301108+hfxsd@users.noreply.github.com> Date: Fri, 3 Feb 2023 21:51:42 +0800 Subject: [PATCH 15/63] sync brian's latest updates --- .../information-schema-processlist.md | 35 +++++----- .../information-schema-resource-groups.md | 68 ++++++------------- .../sql-statement-alter-resource-group.md | 46 ++++++------- .../sql-statement-create-resource-group.md | 37 +++++----- .../sql-statement-drop-resource-group.md | 37 ++++------ ...ql-statement-show-create-resource-group.md | 4 +- tidb-resource-control.md | 57 +++++++++------- tikv-configuration-file.md | 5 +- 8 files changed, 131 insertions(+), 158 deletions(-) diff --git a/information-schema/information-schema-processlist.md b/information-schema/information-schema-processlist.md index 934448b124026..510d056bdebf8 100644 --- a/information-schema/information-schema-processlist.md +++ b/information-schema/information-schema-processlist.md @@ -13,7 +13,7 @@ The `PROCESSLIST` table has additional columns not present in `SHOW PROCESSLIST` * A `MEM` column to show the memory used by the request that is being processed, in bytes. * A `DISK` column to show the disk usage in bytes. * A `TxnStart` column to show the start time of the transaction. -* A `RESOURCE_GROUP_NAME` column to show the resource group name. +* A `RESOURCE_GROUP` column to show the resource group name. {{< copyable "sql" >}} @@ -38,7 +38,7 @@ DESC processlist; | MEM | bigint(21) unsigned | YES | | NULL | | | DISK | bigint(21) unsigned | YES | | NULL | | | TxnStart | varchar(64) | NO | | | | -| RESOURCE_GROUP_NAME | varchar(32) | NO | | | | +| RESOURCE_GROUP | varchar(32) | NO | | | | +---------------------+---------------------+------+------+---------+-------+ 13 rows in set (0.00 sec) ``` @@ -48,13 +48,12 @@ DESC processlist; ```sql SELECT * FROM processlist\G ``` - ```sql *************************** 1. row *************************** - ID: 5794501045170209171 + ID: 2300033189772525975 USER: root - HOST: 127.0.0.1:60645 - DB: information_schema + HOST: 127.0.0.1:51289 + DB: NULL COMMAND: Query TIME: 0 STATE: autocommit @@ -63,7 +62,7 @@ SELECT * FROM processlist\G MEM: 0 DISK: 0 TxnStart: -RESOURCE_GROUP_NAME: default + RESOURCE_GROUP: rg1 1 row in set (0.00 sec) ``` @@ -81,7 +80,7 @@ Fields in the `PROCESSLIST` table are described as follows: * MEM: The memory used by the request that is being processed, in bytes. * DISK: The disk usage in bytes. * TxnStart: The start time of the transaction. -* RESOURCE_GROUP_NAME: The resource group name. +* RESOURCE_GROUP: The resource group name. ## CLUSTER_PROCESSLIST @@ -94,14 +93,14 @@ SELECT * FROM information_schema.cluster_processlist; ``` ```sql -+-----------------+-----+------+----------+------+---------+------+------------+------------------------------------------------------+-----+----------------------------------------+---------------------+ -| INSTANCE | ID | USER | HOST | DB | COMMAND | TIME | STATE | INFO | MEM | TxnStart | RESOURCE_GROUP_NAME | -+-----------------+-----+------+----------+------+---------+------+------------+------------------------------------------------------+-----+----------------------------------------+---------------------+ - -| 10.0.1.22:10080 | 150 | u1 | 10.0.1.1 | test | Query | 0 | autocommit | select count(*) from usertable | 372 | 05-28 03:54:21.230(416976223923077223) | default | -| 10.0.1.22:10080 | 138 | root | 10.0.1.1 | test | Query | 0 | autocommit | SELECT * FROM information_schema.cluster_processlist | 0 | 05-28 03:54:21.230(416976223923077220) | rg1 | -| 10.0.1.22:10080 | 151 | u1 | 10.0.1.1 | test | Query | 0 | autocommit | select count(*) from usertable | 372 | 05-28 03:54:21.230(416976223923077224) | rg2 | -| 10.0.1.21:10080 | 15 | u2 | 10.0.1.1 | test | Query | 0 | autocommit | select max(field0) from usertable | 496 | 05-28 03:54:21.230(416976223923077222) | default | -| 10.0.1.21:10080 | 14 | u2 | 10.0.1.1 | test | Query | 0 | autocommit | select max(field0) from usertable | 496 | 05-28 03:54:21.230(416976223923077225) | default | -+-----------------+-----+------+----------+------+---------+------+------------+------------------------------------------------------+-----+----------------------------------------+---------------------+ ++-----------------+-----+------+----------+------+---------+------+------------+------------------------------------------------------+-----+----------------------------------------+----------------+ +| INSTANCE | ID | USER | HOST | DB | COMMAND | TIME | STATE | INFO | MEM | TxnStart | RESOURCE_GROUP | ++-----------------+-----+------+----------+------+---------+------+------------+------------------------------------------------------+-----+----------------------------------------+----------------+ + +| 10.0.1.22:10080 | 150 | u1 | 10.0.1.1 | test | Query | 0 | autocommit | select count(*) from usertable | 372 | 05-28 03:54:21.230(416976223923077223) | default | +| 10.0.1.22:10080 | 138 | root | 10.0.1.1 | test | Query | 0 | autocommit | SELECT * FROM information_schema.cluster_processlist | 0 | 05-28 03:54:21.230(416976223923077220) | rg1 | +| 10.0.1.22:10080 | 151 | u1 | 10.0.1.1 | test | Query | 0 | autocommit | select count(*) from usertable | 372 | 05-28 03:54:21.230(416976223923077224) | rg2 | +| 10.0.1.21:10080 | 15 | u2 | 10.0.1.1 | test | Query | 0 | autocommit | select max(field0) from usertable | 496 | 05-28 03:54:21.230(416976223923077222) | default | +| 10.0.1.21:10080 | 14 | u2 | 10.0.1.1 | test | Query | 0 | autocommit | select max(field0) from usertable | 496 | 05-28 03:54:21.230(416976223923077225) | default | ++-----------------+-----+------+----------+------+---------+------+------------+------------------------------------------------------+-----+----------------------------------------+----------------+ ``` diff --git a/information-schema/information-schema-resource-groups.md b/information-schema/information-schema-resource-groups.md index 30de61f760f3f..cfd15e501e332 100644 --- a/information-schema/information-schema-resource-groups.md +++ b/information-schema/information-schema-resource-groups.md @@ -11,20 +11,15 @@ DESC resource_groups; ``` ```sql -+-----------------+-------------+------+------+---------+-------+ -| Field | Type | Null | Key | Default | Extra | -+-----------------+-------------+------+------+---------+-------+ -| NAME | varchar(32) | NO | | NULL | | -| MODE | varchar(12) | NO | | NULL | | -| RRU | bigint(21) | YES | | NULL | | -| RRU_TOKEN | bigint(21) | YES | | NULL | | -| WRU | bigint(21) | YES | | NULL | | -| WRU_TOKEN | bigint(21) | YES | | NULL | | -| CPU | bigint(21) | YES | | NULL | | -| READ_BANDWIDTH | bigint(21) | YES | | NULL | | -| WRITE_BANDWIDTH | bigint(21) | YES | | NULL | | -+-----------------+-------------+------+------+---------+-------+ -9 rows in set (0.08 sec) ++------------+-------------+------+------+---------+-------+ +| Field | Type | Null | Key | Default | Extra | ++------------+-------------+------+------+---------+-------+ +| NAME | varchar(32) | NO | | NULL | | +| RU_PER_SEC | bigint(21) | YES | | NULL | | +| RU_TOKENS | bigint(21) | YES | | NULL | | +| BURSTABLE | varchar(3) | YES | | NULL | | ++------------+-------------+------+------+---------+-------+ +4 rows in set (0.00 sec) ``` ## Examples @@ -32,39 +27,18 @@ DESC resource_groups; {{< copyable "sql" >}} ```sql -mysql> CREATE RESOURCE GROUP rg1 RRU_PER_SEC=1000 WRU_PER_SEC=2000 ; -- Use RU_MODE to create the resource group rg1 +mysql> CREATE RESOURCE GROUP rg1 RU_PER_SEC=1000; -- Create the resource group rg1 Query OK, 0 rows affected (0.34 sec) mysql> SHOW CREATE RESOURCE GROUP rg1; -- Displays the definition of the rg1 resource group. -+----------------+------------------------------------------------------------------+ -| Resource_Group | Create Resource Group | -+----------------+------------------------------------------------------------------+ -| rg1 | CREATE RESOURCE GROUP `rg1` RRU_PER_SEC=1000 WRU_PER_SEC=2000 | -+----------------+------------------------------------------------------------------+ ++----------------+---------------------------------------------+ +| Resource_Group | Create Resource Group | ++----------------+---------------------------------------------+ +| rg1 | CREATE RESOURCE GROUP `rg1` RU_PER_SEC=1000 | ++----------------+---------------------------------------------+ 1 row in set (0.00 sec) -mysql> SELECT * FROM information_schema.placement_policies WHERE NAME = 'rg1'; -- Displays the runtime status of the resource group rg1. -+--------+---------+------+-----------+------+-----------+------+----------------+-----------------+ -| NAME | MODE | RRU | RRU_TOKEN | WRU | WRU_TOKEN | CPU | READ_BANDWIDTH | WRITE_BANDWIDTH | -+--------+---------+------+-----------+------+-----------+------+----------------+-----------------+ -| rg1 | RU_MODE | 1000 | 168999 | 2000 | 249999 | NULL | NULL | NULL | -+--------+---------+------+-----------+------+-----------+------+----------------+-----------------+ -1 row in set (0.02 sec) -``` - -```sql -mysql> CREATE RESOURCE GROUP rg2 CPU="8" IO_READ_BANDWIDTH="1000Mi" IO_WRITE_BANDWIDTH="1000Mi"; -- Use RAW_MODE to create the resource group rg2 -Query OK, 0 rows affected (0.20 sec) -mysql> show create resource group rg2; -- Displays the definition of the rg2 resource group. -+----------------+-----------------------------------------------------------------------------------------------+ -| Resource_Group | Create Resource Group | -+----------------+-----------------------------------------------------------------------------------------------+ -| rg2 | CREATE RESOURCE GROUP `rg2` CPU="8" IO_READ_BANDWIDTH="1000Mi" IO_WRITE_BANDWIDTH="1000Mi" | -+----------------+-----------------------------------------------------------------------------------------------+ -1 row in set (0.00 sec) -mysql> SELECT * FROM information_schema.resource_groups WHERE NAME = 'rg2'; -- Displays the runtime status of the resource group rg2. -+--------+----------+------+-----------+------+-----------+------+----------------+-----------------+ -| NAME | MODE | RRU | RRU_TOKEN | WRU | WRU_TOKEN | CPU | READ_BANDWIDTH | WRITE_BANDWIDTH | -+--------+----------+------+-----------+------+-----------+------+----------------+-----------------+ -| rg2 | RAW_MODE | NULL | NULL | NULL | NULL | 8000 | 1048576000 | 1048576000 | -+--------+----------+------+-----------+------+-----------+------+----------------+-----------------+ -1 row in set (0.00 sec) -``` +mysql> SELECT * FROM information_schema.resource_groups WHERE NAME = 'rg1'; ++------+------------+-----------+-----------+ +| NAME | RU_PER_SEC | RU_TOKENS | BURSTABLE | ++------+------------+-----------+-----------+ +| rg1 | 1000 | 100000 | NO | ++------+------------+-----------+-----------+ diff --git a/sql-statements/sql-statement-alter-resource-group.md b/sql-statements/sql-statement-alter-resource-group.md index 2fa605e889c2b..29da65a9d9961 100644 --- a/sql-statements/sql-statement-alter-resource-group.md +++ b/sql-statements/sql-statement-alter-resource-group.md @@ -33,14 +33,13 @@ BurstableOption ::= ``` -TiDB supports the following `DirectResourceGroupOption`, where [RU (Resource Unit)](/tidb-RU.md) is TiDB's unified abstraction unit for CPU, IO, and other system resources. +TiDB supports the following `DirectResourceGroupOption`, where [RU (Request Unit)](/tidb-RU.md) is TiDB's unified abstraction unit for CPU, IO, and other system resources. | Option | Description | Example | |---------------|-------------------------------------|------------------------| -|`RRU_PER_SEC` | Quota of read RU per second |`RRU_PER_SEC = 500` | -|`WRU_PER_SEC` | Quota of write RU per second |`WRU_PER_SEC = 300` | +|`RU_PER_SEC` | Rate of RU filling per second |`RU_PER_SEC = 500` indicates that this resource group is backfilled with 500 RU per second | -If the `BURSTABLE` attribute is set, the corresponding resource group allows the system resources to be used exceeding the quota if the system resources are sufficient. +If the `BURSTABLE` attribute is set, the corresponding resource group allows the system resources to be used exceeding the quota. > **Note:** > @@ -54,31 +53,26 @@ Create a resource group named `rg1` and modify its properties. mysql> DROP RESOURCE GROUP IF EXISTS rg1; Query OK, 0 rows affected (0.22 sec) mysql> CREATE RESOURCE GROUP IF NOT EXISTS rg1 - -> RRU_PER_SEC = 500 - -> WRU_PER_SEC = 300 - -> BURSTABLE - -> ; + -> RU_PER_SEC = 100 + -> BURSTABLE; Query OK, 0 rows affected (0.08 sec) mysql> SELECT * FROM information_schema.resource_groups WHERE NAME ='rg1'; -+------+--------------+---------------------------------------------------------------+ -| Name | Plan_type | Directive | -+------+--------------+---------------------------------------------------------------+ -| rg1 | tenancy | {"RRU_PER_SEC": 500, "WRU_PER_SEC": 300, "BURSTABLE": true} | -+------+--------------+---------------------------------------------------------------+ -1 row in set (0.00 sec) - -mysql> ALTER RESOURCE GROUP IF NOT EXISTS rg1 - -> RRU_PER_SEC = 600 - -> WRU_PER_SEC = 400 - -> ; -Query OK, 0 rows affected (0.09 sec) ++------+-------------+-----------+-----------+ +| NAME | RU_PER_SEC | RU_TOKENS | BURSTABLE | ++------+-------------+-----------+-----------+ +| rg1 | 100 | 165135 | YES | ++------+-------------+-----------+-----------+ +1 rows in set (1.30 sec) +mysql> ALTER RESOURCE GROUP rg1 + -> RU_PER_SEC = 200; +Query OK, 0 rows affected (0.08 sec) mysql> SELECT * FROM information_schema.resource_groups WHERE NAME ='rg1'; -+------+--------------+---------------------------------------------------------------+ -| Name | Plan_type | Directive | -+------+--------------+---------------------------------------------------------------+ -| rg1 | tenancy | {"RRU_PER_SEC": 600, "WRU_PER_SEC": 400, "BURSTABLE": false} | -+------+--------------+---------------------------------------------------------------+ -1 row in set (0.00 sec) ++------+-------------+-----------+-----------+ +| NAME | RU_PER_SEC | RU_TOKENS | BURSTABLE | ++------+-------------+-----------+-----------+ +| rg1 | 200 | 257158 | NO | ++------+-------------+-----------+-----------+ +1 rows in set (1.30 sec) ``` ## MySQL compatibility diff --git a/sql-statements/sql-statement-create-resource-group.md b/sql-statements/sql-statement-create-resource-group.md index ff3ee76fb4197..a6bf053e2cca0 100644 --- a/sql-statements/sql-statement-create-resource-group.md +++ b/sql-statements/sql-statement-create-resource-group.md @@ -25,8 +25,7 @@ ResourceGroupOptionList: | ResourceGroupOptionList ',' DirectResourceGroupOption DirectResourceGroupOption: - "RRU_PER_SEC" EqOpt stringLit -| "WRU_PER_SEC" EqOpt stringLit + "RU_PER_SEC" EqOpt stringLit BurstableOption ::= ("BURSTABLE")? @@ -35,14 +34,13 @@ BurstableOption ::= The resource group name parameter (`ResourceGroupName`) is globally unique and cannot be duplicated. -TiDB supports the following `DirectResourceGroupOption`, where [RU (Resource Unit)](/tidb-RU.md) is TiDB's unified abstraction unit for CPU, IO, and other system resources. +TiDB supports the following `DirectResourceGroupOption`, where [RU (Request Unit)](/tidb-RU.md) is TiDB's unified abstraction unit for CPU, IO, and other system resources. | Option | Description | Example | |---------------|-------------------------------------|------------------------| -|`RRU_PER_SEC` | Quota of RU read per second |`RRU_PER_SEC = 500` | -|`WRU_PER_SEC` | Quota of RU write per second |`WRU_PER_SEC = 300` | +|`RU_PER_SEC` | Rate of RU filling per second |`RU_PER_SEC = 500` indicates that this resource group is backfilled with 500 RU per second | -If the `BURSTABLE` attribute is set, the corresponding resource group allows the system resources to be used exceeding the quota if the system resources are sufficient. +If the `BURSTABLE` attribute is set, the corresponding resource group allows the system resources to be used exceeding the quota. > **Note:** > @@ -50,24 +48,27 @@ If the `BURSTABLE` attribute is set, the corresponding resource group allows the ## Examples -Create a resource group named `rg1`. +Create two resource groups `rg1` and `rg2`. ```sql mysql> DROP RESOURCE GROUP IF EXISTS rg1; Query OK, 0 rows affected (0.22 sec) mysql> CREATE RESOURCE GROUP IF NOT EXISTS rg1 - -> RRU_PER_SEC = 500 - -> WRU_PER_SEC = 300 - -> BURSTABLE - -> ; + -> RU_PER_SEC = 100 + -> BURSTABLE; Query OK, 0 rows affected (0.08 sec) -mysql> SELECT * FROM information_schema.resource_groups WHERE NAME ='rg1'; -+------+--------------+---------------------------------------------------------------+ -| Name | Plan_type | Directive | -+------+--------------+---------------------------------------------------------------+ -| rg1 | tenancy | {"RRU_PER_SEC": 500, "WRU_PER_SEC": 300, "BURSTABLE": true} | -+------+--------------+---------------------------------------------------------------+ -1 row in set (0.00 sec) +mysql> CREATE RESOURCE GROUP IF NOT EXISTS rg2 + -> RU_PER_SEC = 200 + -> BURSTABLE; +Query OK, 0 rows affected (0.08 sec) +mysql> SELECT * FROM information_schema.resource_groups WHERE NAME ='rg1' or NAME = 'rg2'; ++------+-------------+-----------+-----------+ +| NAME | RU_PER_SEC | RU_TOKENS | BURSTABLE | ++------+-------------+-----------+-----------+ +| rg1 | 100 | 165135 | YES | +| rg2 | 200 | 157158 | NO | ++------+-------------+-----------+-----------+ +2 rows in set (1.30 sec) ``` ## MySQL compatibility diff --git a/sql-statements/sql-statement-drop-resource-group.md b/sql-statements/sql-statement-drop-resource-group.md index 9c68334564084..47d1e01bfe8bc 100644 --- a/sql-statements/sql-statement-drop-resource-group.md +++ b/sql-statements/sql-statement-drop-resource-group.md @@ -11,10 +11,10 @@ You can use the `DROP RESOURCE GROUP` statement to drop a resource group in the ```ebnf+diagram DropResourceGroupStmt: - "DROP" "RESOURCE" "GROUP" IfNotExists ResourceGroupName + "DROP" "RESOURCE" "GROUP" IfExists ResourceGroupName -IfNotExists ::= - ('IF' 'NOT' 'EXISTS')? +IfExists ::= + ('IF' 'EXISTS')? ResourceGroupName: Identifier @@ -31,28 +31,21 @@ Drop a resource group named `rg1`. ```sql mysql> DROP RESOURCE GROUP IF EXISTS rg1; Query OK, 0 rows affected (0.22 sec) -mysql> CREATE RESOURCE GROUP IF NOT EXISTS rg1 ( - -> RRU_PER_SEC = 500 - -> WRU_PER_SEC = 300 - -> BURSTABLE - -> ); +mysql> CREATE RESOURCE GROUP IF NOT EXISTS rg1 RU_PER_SEC = 500 BURSTABLE; Query OK, 0 rows affected (0.08 sec) mysql> SELECT * FROM information_schema.resource_groups WHERE NAME ='rg1'; -+------+--------------+---------------------------------------------------------------+ -| Name | Plan_type | Directive | -+------+--------------+---------------------------------------------------------------+ -| rg1 | tenancy | {"RRU_PER_SEC": 500, "WRU_PER_SEC": 300, "BURSTABLE": true} | -+------+--------------+---------------------------------------------------------------+ -1 row in set (0.00 sec) - -mysql> DROP RESOURCE GROUP IF NOT EXISTS rg1 ; ++------+------------+-----------+-----------+ +| NAME | RU_PER_SEC | RU_TOKENS | BURSTABLE | ++------+------------+-----------+-----------+ +| rg1 | 500 | 0 | YES | ++------+------------+-----------+-----------+ +1 row in set (0.01 sec) + +mysql> DROP RESOURCE GROUP IF EXISTS rg1 ; Query OK, 1 rows affected (0.09 sec) -mysql> SELECT * FROM information_schema.resource_groups WHERE NAME ='rg1'; -+------+--------------+---------------------------------------------------------------+ -| Name | Plan_type | Directive | -+------+--------------+---------------------------------------------------------------+ -+------+--------------+---------------------------------------------------------------+ -0 row in set (0.00 sec) + +mysql> SELECT * FROM information_schema.resource_groups WHERE NAME ='rg1'; +Empty set (0.00 sec) ``` ## MySQL compatibility diff --git a/sql-statements/sql-statement-show-create-resource-group.md b/sql-statements/sql-statement-show-create-resource-group.md index 031622acbbe0e..e3a8ae72071c3 100644 --- a/sql-statements/sql-statement-show-create-resource-group.md +++ b/sql-statements/sql-statement-show-create-resource-group.md @@ -22,7 +22,7 @@ ResourceGroupName ::= View the current definition of the resource group `rg1`. ```sql -CREATE RESOURCE GROUP rg1 RRU_PER_SEC=100 WRU_PER_SEC=200; +CREATE RESOURCE GROUP rg1 RU_PER_SEC=100; Query OK, 0 rows affected (0.10 sec) ``` @@ -30,7 +30,7 @@ Query OK, 0 rows affected (0.10 sec) SHOW CREATE RESOURCE GROUP rg1; ***************************[ 1. row ]*************************** Resource_Group | rg1 -Create Resource Group | CREATE RESOURCE GROUP `rg1` RRU_PER_SEC=100 WRU_PER_SEC=200 +Create Resource Group | CREATE RESOURCE GROUP `rg1` RU_PER_SEC=100 1 row in set (0.00 sec) ``` diff --git a/tidb-resource-control.md b/tidb-resource-control.md index 87efa1311d84c..14c2b717fce60 100644 --- a/tidb-resource-control.md +++ b/tidb-resource-control.md @@ -28,12 +28,30 @@ In addition, the rational use of the resource control feature can reduce the num +## What is Request Unit (RU) + +Request Unit (RU) is TiDB's unified abstraction unit for CPU, IO and other system resources, which currently includes CPU, IOPS and IO bandwidth metrics. The consumption of these three metrics is represented by the RU unit according to a certain ratio. + +The following table shows the consumption of TiKV storage layer CPU and IO resources by user requests and the corresponding RU weights. + +| Resource | RU Weight | +|:----------|:------| +| CPU | 1 RU / Milliseconds | +| Read IO | 1 RU / MiB | +| Write IO | 5 RU / MiB | +| Basic overhead of a read request | 1 RU | +| Basic overhead of a write request | 3 RU | + +Based on the above table, assuming that the TiKV time consumed by a resource group is `c` milliseconds, `r1` requests that read `r2` MiB data, and `w1` write requests that write `w2` MiB data, then the formula for the total RUs consumed by the resource group is as follows: + +c + (r1 + r2) + (3 * w1 + 5 * w2) + ## Parameters for resource control The resource control feature introduces two new global variables. -* TiDB: you can use the system variable [`tidb_enable_resource_control`](/system-variables.md#tidb-tidb_enable_resource_control) to control whether to enable flow control for a resource group. -* TiKV: you can use the parameter [`resource_control.enabled`](/tikv-configuration-file.md#resource_control) to control whether to use request scheduling based on resource group quotas. +* TiDB: you can use the system variable [`tidb_enable_resource_control`](/system-variables.md#tidb-tidb_enable_resource_control) to control whether to enable flow control for a resource group. +* TiKV: you can use the parameter [`resource_control.enabled`](/tikv-configuration-file.md#resource_control) to control whether to use request scheduling based on resource group quotas. @@ -52,20 +70,18 @@ The results of the combinations of these two parameters are shown in the followi ## How to use resource control +To create, modify, or delete a resource group, you need to have the `SUPER` or `RESOURCE_GROUP_ADMIN` privilege. + +You can create a resource group in the cluster by using [`CREATE RESOURCE GROUP`](/sql-statements/sql-statement-create-resource-group.md), and then bind the users to a specific resource group by using [`CREATE USER`](/sql-statements/ sql-statement-create-user.md) or [`ALTER USER`](/sql-statements/sql-statement-alter-user.md). + For an existing resource group, you can modify the read and write quota of the resource group by using [`ALTER RESOURCE GROUP`](/sql-statements/sql-statement-alter-resource-group.md). The quota changes to the resource group take effect immediately. -You can delete a resource group by using [`DROP RESOURCE GROUP`](/sql-statements/sql-statement-drop-resource-group.md). The user bound to the deleted resource group will use the `default` resource group for resource isolation. +You can delete a resource group by using [`DROP RESOURCE GROUP`](/sql-statements/sql-statement-drop-resource-group.md). > **Note:** > > - When you bind a user to a resource group by using `CREATE USER` or `ALTER USER`, it will not take effect for the user's existing sessions, but only for the user's new sessions. -> - The `default` resource group does not have quota restrictions for the user's applications. It is recommended to create the `default` resource group by using [`CREATE RESOURCE GROUP`](/sql-statements/sql-statement-create-resource-group.md), or modify the quota for the `default` resource group by using [`ALTER RESOURCE GROUP`](/sql-statements/sql-statement-alter-resource-group.md) to control the quota for the `default` resource group. - -### Prerequisites - -To create, modify, or delete a resource group, you need to have the `SUPER` or `RESOURCE_GROUP_ADMIN` privilege. - -You can create a resource group in the cluster by using [`CREATE RESOURCE GROUP`](/sql-statements/sql-statement-create-resource-group.md), and then bind the users to a specific resource group by using [`CREATE USER`](/sql-statements/ sql-statement-create-user.md) or [`ALTER USER`](/sql-statements/sql-statement-alter-user.md). +> - If a user is not bound to a resource group or is bound to a `default` resource group, the user's requests are not subject to TiDB's flow control restrictions. The `default` resource group is currently not visible to the user and cannot be created or modified. ### Step 1. Enable the resource control feature @@ -83,27 +99,20 @@ In TiKV, set the parameter `resource_control.enabled` to `true`. The parameter ` ### Step 2. Create a resource group, and then bind users to it -Resource group quotas are expressed as [RU (Resource Unit)](/tidb-RU.md), which is TiDB's unified abstraction of CPU, IO, and other system resources. +Resource group quotas are expressed as [RU (Request Unit)](/tidb-RU.md), which is TiDB's unified abstraction of CPU, IO, and other system resources. The following is an example of how to create a resource group and bind users to it. -1. Create a resource group `rg1` with a quota of 500 RU per second for read requests and 300 RU per second for write requests, and allow applications in this resource group to use excessive resources when system resources are available. +1. Create a resource group `rg1`. The RU backfill rate is 500 RU per second and allows applications in this resource group to overrun resources. ```sql - CREATE RESOURCE GROUP IF NOT EXISTS rg1 - RRU_PER_SEC = 500 - WRU_PER_SEC = 300 - BURSTABLE - ; + CREATE RESOURCE GROUP IF NOT EXISTS rg1 RU_PER_SEC = 500 BURSTABLE; ``` -2. Create a resource group `rg2` with a quota of 600 RU per second for read requests and 400 RU per second for write requests, and do not allow applications in this resource group to use excessive resources even when system resources are available. +2. Create a resource group `rg2`. The RU backfill rate is 500 RU per second and does not allow applications in this resource group to overrun resources. ```sql - CREATE RESOURCE GROUP IF NOT EXISTS rg2 - RRU_PER_SEC = 600 - WRU_PER_SEC = 400 - ; + CREATE RESOURCE GROUP IF NOT EXISTS rg2 RU_PER_SEC = 600; ``` 3. Bind users `usr1` and `usr2` to resource groups `rg1` and `rg2` respectively. @@ -116,7 +125,9 @@ The following is an example of how to create a resource group and bind users to ALTER USER usr2 RESOURCE GROUP rg2; ``` -After you complete the preceding operations, the resource consumption by newly created sessions is controlled by the specified quota. Read requests are limited by the read RU quota, and write requests are limited by the write RU quota. If the system load is relatively high and there is no spare capacity, the resource consumption rate of both users will be strictly controlled not to exceed the quota. Meanwhile, the consumption ratio of RU metrics for both users' read and write requests is basically proportional to the specified quota. When system resources are abundant, the resource consumption rate of `usr1` is allowed to exceed the quota because it has set `BURSTABLE`, while `usr2` is not allowed. +After you complete the above operations of creating resource groups and binding users, the resource consumption of newly created sessions will be controlled by the specified quota. If the system load is relatively high and there is no spare capacity, the resource consumption rate of `usr2` will be strictly controlled not to exceed the quota. Because `usr1` bound by `rg1` is configured with `BURSTABLE`, the consumption rate of `usr1` is allowed to exceed the quota. + +If the resource group corresponds to a request with insufficient quota, the client's request will wait. If the wait time is too long, the request will report an error. ## Monitoring and charts diff --git a/tikv-configuration-file.md b/tikv-configuration-file.md index 4477efa95e39a..7ef7f2429011f 100644 --- a/tikv-configuration-file.md +++ b/tikv-configuration-file.md @@ -2158,9 +2158,10 @@ To reduce write latency, TiKV periodically fetches and caches a batch of timesta ## resource_control -Configuration items related to resource control. +Configuration items related to resource control related to the TiKV storage layer. ### `enabled` New in v6.6.0 -+ Control whether to use read/write request scheduling based on resource group quotas. ++ Whether to support prioritized scheduling for user foreground read/write requests according to the corresponding resource group quota. For information about TiDB resource groups and resource control, see [TiDB resource control](/tidb-resource-control.md) ++ It is only meaningful to enable this configuration item if [`tidb_enable_resource_control](/system-variables.md#tidb_enable_resource_control-new-in-v660) is enabled on TiDB side. When it is enabled, TiKV will use the priority queue to schedule the queued requests for user foreground read/write requests. The priority of scheduling is inversely related to the amount of resources already consumed by the resource group where the request is located, and positively related to the quota of the corresponding resource group. + Default value: `false`, which means to disable scheduling based on resource group quotas. \ No newline at end of file From 9a4f4ba79a11e14c7328d33d4ecead454292fe66 Mon Sep 17 00:00:00 2001 From: xixirangrang Date: Mon, 6 Feb 2023 09:31:57 +0800 Subject: [PATCH 16/63] Update tidb-resource-control.md --- tidb-resource-control.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tidb-resource-control.md b/tidb-resource-control.md index 14c2b717fce60..5c5b69fe363cc 100644 --- a/tidb-resource-control.md +++ b/tidb-resource-control.md @@ -50,7 +50,7 @@ c + (r1 + r2) + (3 * w1 + 5 * w2) The resource control feature introduces two new global variables. -* TiDB: you can use the system variable [`tidb_enable_resource_control`](/system-variables.md#tidb-tidb_enable_resource_control) to control whether to enable flow control for a resource group. +* TiDB: you can use the system variable [`tidb_enable_resource_control`](/system-variables.md#tidb-tidb_enable_resource_control-new-in-v660) to control whether to enable flow control for a resource group. * TiKV: you can use the parameter [`resource_control.enabled`](/tikv-configuration-file.md#resource_control) to control whether to use request scheduling based on resource group quotas. From f9d992f14879316910c87b116a4b5b90af11e688 Mon Sep 17 00:00:00 2001 From: xixirangrang Date: Mon, 6 Feb 2023 09:35:20 +0800 Subject: [PATCH 17/63] Apply suggestions from code review Co-authored-by: BornChanger <97348524+BornChanger@users.noreply.github.com> --- grafana-resource-control-dashboard.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grafana-resource-control-dashboard.md b/grafana-resource-control-dashboard.md index ccc663f999f91..c444c96d62462 100644 --- a/grafana-resource-control-dashboard.md +++ b/grafana-resource-control-dashboard.md @@ -13,9 +13,9 @@ You can get an overview of the resource control status from the PD dashboard, wh The following is the description of Resource Control Dashboard metrics items. -## Resource Unit +## Request Unit -- RU: the [Resource Unit](/tidb-RU.md) consumption information of each Resource Group is calculated in real time. `total` is the sum of the Request Units consumed by all Resource Groups. The Request Unit consumption of each Resource Group should be equal to the sum of its read consumption (Read Request Unit) and write consumption (Write Request Unit). +- RU: the [Request Unit](/tidb-RU.md) consumption information of each Resource Group is calculated in real time. `total` is the sum of the Request Units consumed by all Resource Groups. The Request Unit consumption of each Resource Group should be equal to the sum of its read consumption (Read Request Unit) and write consumption (Write Request Unit). - RU Per Query: the average number of Request Units consumed by each SQL statement per second is obtained by dividing the above Request Unit by the number of SQL statements executed per second. - RRU: the Read Request Unit consumption information of each Resource Group is calculated in real time. `total` is the sum of the Read Request Units consumed by all Resource Groups. - RRU Per Query: the average number of Read Request Units consumed by each SQL statement per second is obtained by dividing the above Read Request Unit by the number of SQL statements executed per second. From 5fedf74f70aa0cd7b35bfeee6d6cdd8f3564b742 Mon Sep 17 00:00:00 2001 From: xixirangrang <35301108+hfxsd@users.noreply.github.com> Date: Mon, 6 Feb 2023 10:22:26 +0800 Subject: [PATCH 18/63] fix links --- grafana-resource-control-dashboard.md | 2 +- sql-statements/sql-statement-alter-resource-group.md | 4 ++-- sql-statements/sql-statement-create-resource-group.md | 4 ++-- sql-statements/sql-statement-drop-resource-group.md | 2 +- tidb-resource-control.md | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/grafana-resource-control-dashboard.md b/grafana-resource-control-dashboard.md index c444c96d62462..16dd982daaf43 100644 --- a/grafana-resource-control-dashboard.md +++ b/grafana-resource-control-dashboard.md @@ -15,7 +15,7 @@ The following is the description of Resource Control Dashboard metrics items. ## Request Unit -- RU: the [Request Unit](/tidb-RU.md) consumption information of each Resource Group is calculated in real time. `total` is the sum of the Request Units consumed by all Resource Groups. The Request Unit consumption of each Resource Group should be equal to the sum of its read consumption (Read Request Unit) and write consumption (Write Request Unit). +- RU: the [Request Unit](/tidb-resource-control.md#what-is-request-unit-ru) consumption information of each Resource Group is calculated in real time. `total` is the sum of the Request Units consumed by all Resource Groups. The Request Unit consumption of each Resource Group should be equal to the sum of its read consumption (Read Request Unit) and write consumption (Write Request Unit). - RU Per Query: the average number of Request Units consumed by each SQL statement per second is obtained by dividing the above Request Unit by the number of SQL statements executed per second. - RRU: the Read Request Unit consumption information of each Resource Group is calculated in real time. `total` is the sum of the Read Request Units consumed by all Resource Groups. - RRU Per Query: the average number of Read Request Units consumed by each SQL statement per second is obtained by dividing the above Read Request Unit by the number of SQL statements executed per second. diff --git a/sql-statements/sql-statement-alter-resource-group.md b/sql-statements/sql-statement-alter-resource-group.md index 29da65a9d9961..37d84d0edefbc 100644 --- a/sql-statements/sql-statement-alter-resource-group.md +++ b/sql-statements/sql-statement-alter-resource-group.md @@ -33,7 +33,7 @@ BurstableOption ::= ``` -TiDB supports the following `DirectResourceGroupOption`, where [RU (Request Unit)](/tidb-RU.md) is TiDB's unified abstraction unit for CPU, IO, and other system resources. +TiDB supports the following `DirectResourceGroupOption`, where [Request Unit (RU)](/tidb-resource-control.md#what-is-request-unit-ru) is TiDB's unified abstraction unit for CPU, IO, and other system resources. | Option | Description | Example | |---------------|-------------------------------------|------------------------| @@ -83,4 +83,4 @@ MySQL also supports [ALTER RESOURCE GROUP](https://dev.mysql.com/doc/refman/8.0/ * [DROP RESOURCE GROUP](/sql-statements/sql-statement-drop-resource-group.md) * [CREATE RESOURCE GROUP](/sql-statements/sql-statement-create-resource-group.md) -* [RU](/tidb-RU.md) +* [Request Unit (RU)](/tidb-resource-control.md#what-is-request-unit-ru) diff --git a/sql-statements/sql-statement-create-resource-group.md b/sql-statements/sql-statement-create-resource-group.md index a6bf053e2cca0..eb67b8fa45ea5 100644 --- a/sql-statements/sql-statement-create-resource-group.md +++ b/sql-statements/sql-statement-create-resource-group.md @@ -34,7 +34,7 @@ BurstableOption ::= The resource group name parameter (`ResourceGroupName`) is globally unique and cannot be duplicated. -TiDB supports the following `DirectResourceGroupOption`, where [RU (Request Unit)](/tidb-RU.md) is TiDB's unified abstraction unit for CPU, IO, and other system resources. +TiDB supports the following `DirectResourceGroupOption`, where [Request Unit (RU)](/tidb-resource-control.md#what-is-request-unit-ru) is TiDB's unified abstraction unit for CPU, IO, and other system resources. | Option | Description | Example | |---------------|-------------------------------------|------------------------| @@ -79,4 +79,4 @@ MySQL also supports [CREATE RESOURCE GROUP](https://dev.mysql.com/doc/refman/8.0 * [DROP RESOURCE GROUP](/sql-statements/sql-statement-drop-resource-group.md) * [ALTER RESOURCE GROUP](/sql-statements/sql-statement-alter-resource-group.md) -* [RU](/tidb-RU.md) +* [Request Unit (RU)](/tidb-resource-control.md#what-is-request-unit-ru) diff --git a/sql-statements/sql-statement-drop-resource-group.md b/sql-statements/sql-statement-drop-resource-group.md index 47d1e01bfe8bc..ae22d67263394 100644 --- a/sql-statements/sql-statement-drop-resource-group.md +++ b/sql-statements/sql-statement-drop-resource-group.md @@ -56,4 +56,4 @@ MySQL also supports [DROP RESOURCE GROUP](https://dev.mysql.com/doc/refman/8.0/e * [ALTER RESOURCE GROUP](/sql-statements/sql-statement-alter-resource-group.md) * [CREATE RESOURCE GROUP](/sql-statements/sql-statement-create-resource-group.md) -* [RU](/tidb-RU.md) \ No newline at end of file +* [Request Unit (RU)](/tidb-resource-control.md#what-is-request-unit-ru) \ No newline at end of file diff --git a/tidb-resource-control.md b/tidb-resource-control.md index 5c5b69fe363cc..810e4de67ff77 100644 --- a/tidb-resource-control.md +++ b/tidb-resource-control.md @@ -99,7 +99,7 @@ In TiKV, set the parameter `resource_control.enabled` to `true`. The parameter ` ### Step 2. Create a resource group, and then bind users to it -Resource group quotas are expressed as [RU (Request Unit)](/tidb-RU.md), which is TiDB's unified abstraction of CPU, IO, and other system resources. +Resource group quotas are expressed as [Request Unit (RU)](/tidb-resource-control.md#what-is-request-unit-ru), which is TiDB's unified abstraction of CPU, IO, and other system resources. The following is an example of how to create a resource group and bind users to it. @@ -150,4 +150,4 @@ Currently, the resource control feature has the following limitations: * [ALTER RESOURCE GROUP](/sql-statements/sql-statement-alter-resource-group.md) * [DROP RESOURCE GROUP](/sql-statements/sql-statement-drop-resource-group.md) * [RESOURCE GROUP RFC](https://docs.google.com/document/d/1sV5EVv8Cdpc6aBCDihc2akpE0iuantPf/) -* [RU](/tidb-RU.md) +* [Request Unit (RU)](/tidb-resource-control.md#what-is-request-unit-ru) From 413aba29ed10dc6b444c94e909fe2aff8bd85024 Mon Sep 17 00:00:00 2001 From: xixirangrang <35301108+hfxsd@users.noreply.github.com> Date: Mon, 6 Feb 2023 10:40:12 +0800 Subject: [PATCH 19/63] Update tidb-resource-control.md --- tidb-resource-control.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tidb-resource-control.md b/tidb-resource-control.md index 810e4de67ff77..ea3968409e510 100644 --- a/tidb-resource-control.md +++ b/tidb-resource-control.md @@ -79,7 +79,7 @@ For an existing resource group, you can modify the read and write quota of the r You can delete a resource group by using [`DROP RESOURCE GROUP`](/sql-statements/sql-statement-drop-resource-group.md). > **Note:** -> +> > - When you bind a user to a resource group by using `CREATE USER` or `ALTER USER`, it will not take effect for the user's existing sessions, but only for the user's new sessions. > - If a user is not bound to a resource group or is bound to a `default` resource group, the user's requests are not subject to TiDB's flow control restrictions. The `default` resource group is currently not visible to the user and cannot be created or modified. @@ -99,8 +99,6 @@ In TiKV, set the parameter `resource_control.enabled` to `true`. The parameter ` ### Step 2. Create a resource group, and then bind users to it -Resource group quotas are expressed as [Request Unit (RU)](/tidb-resource-control.md#what-is-request-unit-ru), which is TiDB's unified abstraction of CPU, IO, and other system resources. - The following is an example of how to create a resource group and bind users to it. 1. Create a resource group `rg1`. The RU backfill rate is 500 RU per second and allows applications in this resource group to overrun resources. @@ -150,4 +148,3 @@ Currently, the resource control feature has the following limitations: * [ALTER RESOURCE GROUP](/sql-statements/sql-statement-alter-resource-group.md) * [DROP RESOURCE GROUP](/sql-statements/sql-statement-drop-resource-group.md) * [RESOURCE GROUP RFC](https://docs.google.com/document/d/1sV5EVv8Cdpc6aBCDihc2akpE0iuantPf/) -* [Request Unit (RU)](/tidb-resource-control.md#what-is-request-unit-ru) From 60f6d3095563bf604cf6b0892c9dcb3e525ea415 Mon Sep 17 00:00:00 2001 From: xixirangrang <35301108+hfxsd@users.noreply.github.com> Date: Mon, 6 Feb 2023 22:43:03 +0800 Subject: [PATCH 20/63] translated the newly added content --- .../information-schema-resource-groups.md | 13 +++++++++++++ .../sql-statement-alter-resource-group.md | 13 +++++-------- .../sql-statement-create-resource-group.md | 7 ++----- tidb-resource-control.md | 9 ++++++++- 4 files changed, 28 insertions(+), 14 deletions(-) diff --git a/information-schema/information-schema-resource-groups.md b/information-schema/information-schema-resource-groups.md index cfd15e501e332..165a09ccae692 100644 --- a/information-schema/information-schema-resource-groups.md +++ b/information-schema/information-schema-resource-groups.md @@ -3,6 +3,12 @@ title: RESOURCE_GROUPS summary: Learn the `RESOURCE_GROUPS` information_schema table. --- +# RESOURCE_GROUPS + +> **Warning:** +> +> This feature is experimental and its form and usage may change in subsequent versions. + The `RESOURCE_GROUPS` table shows information about all resource groups. See [Use Resource Control to Achieve Resource Isolation](/tidb-resource-control.md). ```sql @@ -42,3 +48,10 @@ mysql> SELECT * FROM information_schema.resource_groups WHERE NAME = 'rg1'; +------+------------+-----------+-----------+ | rg1 | 1000 | 100000 | NO | +------+------------+-----------+-----------+ + +The descriptions of the columns in the `RESOURCE_GROUPS` table are as follows: + +* `NAME`: the name of the resource group. +* `RU_PER_SEC`:the backfilling speed of the resource group in [Request Unit (RU)](/tidb-resource-control.md#what-is-request-unit-ru)/second. +* `RU_TOKENS`: the number of tokens left in the resource group token bucket, and 1 token is an RU. +* `BURSTABLE`: whether to allow this resource group to overuse the remaining system resources. diff --git a/sql-statements/sql-statement-alter-resource-group.md b/sql-statements/sql-statement-alter-resource-group.md index 37d84d0edefbc..2bd9ae3e18457 100644 --- a/sql-statements/sql-statement-alter-resource-group.md +++ b/sql-statements/sql-statement-alter-resource-group.md @@ -11,10 +11,10 @@ The `ALTER RESOURCE GROUP` statement is used to modify the resource group in a d ```ebnf+diagram AlterResourceGroupStmt: - "ALTER" "RESOURCE" "GROUP" IfNotExists ResourceGroupName ResourceGroupOptionList BurstableOption + "ALTER" "RESOURCE" "GROUP" IfNotExists ResourceGroupName ResourceGroupOptionList IfNotExists ::= - ('IF' 'NOT' 'EXISTS')? + ('IF' 'EXISTS')? ResourceGroupName: Identifier @@ -25,11 +25,8 @@ ResourceGroupOptionList: | ResourceGroupOptionList ',' DirectResourceGroupOption DirectResourceGroupOption: - "RRU_PER_SEC" EqOpt stringLit -| "WRU_PER_SEC" EqOpt stringLit - -BurstableOption ::= - ("BURSTABLE")? + "RU_PER_SEC" EqOpt stringLit +| "BURSTABLE" ``` @@ -39,7 +36,7 @@ TiDB supports the following `DirectResourceGroupOption`, where [Request Unit (RU |---------------|-------------------------------------|------------------------| |`RU_PER_SEC` | Rate of RU filling per second |`RU_PER_SEC = 500` indicates that this resource group is backfilled with 500 RU per second | -If the `BURSTABLE` attribute is set, the corresponding resource group allows the system resources to be used exceeding the quota. +If the `BURSTABLE` attribute is set, the corresponding resource group allows the available system resources to be used exceeding the quota. > **Note:** > diff --git a/sql-statements/sql-statement-create-resource-group.md b/sql-statements/sql-statement-create-resource-group.md index eb67b8fa45ea5..277e83670eff3 100644 --- a/sql-statements/sql-statement-create-resource-group.md +++ b/sql-statements/sql-statement-create-resource-group.md @@ -11,7 +11,7 @@ You can use the `CREATE RESOURCE GROUP` statement to create a resource group in ```ebnf+diagram CreateResourceGroupStmt: - "CREATE" "RESOURCE" "GROUP" IfNotExists ResourceGroupName ResourceGroupOptionList BurstableOption + "CREATE" "RESOURCE" "GROUP" IfNotExists ResourceGroupName ResourceGroupOptionList IfNotExists ::= ('IF' 'NOT' 'EXISTS')? @@ -26,9 +26,7 @@ ResourceGroupOptionList: DirectResourceGroupOption: "RU_PER_SEC" EqOpt stringLit - -BurstableOption ::= - ("BURSTABLE")? +| "BURSTABLE" ``` @@ -59,7 +57,6 @@ mysql> CREATE RESOURCE GROUP IF NOT EXISTS rg1 Query OK, 0 rows affected (0.08 sec) mysql> CREATE RESOURCE GROUP IF NOT EXISTS rg2 -> RU_PER_SEC = 200 - -> BURSTABLE; Query OK, 0 rows affected (0.08 sec) mysql> SELECT * FROM information_schema.resource_groups WHERE NAME ='rg1' or NAME = 'rg2'; +------+-------------+-----------+-----------+ diff --git a/tidb-resource-control.md b/tidb-resource-control.md index ea3968409e510..4fe87a544a0f3 100644 --- a/tidb-resource-control.md +++ b/tidb-resource-control.md @@ -11,7 +11,14 @@ summary: Learn how to use resource management to control and schedule applicatio Using the resource control feature, as a cluster administrator, you can define resource groups and limit the read and write quotas by resource groups. After you bind users to a resource group, the TiDB layer will perform flow control on the user's read and write requests according to the read and write quotas set by the bound resource group. Meanwhile, the TiKV layer will schedule the requests according to the priority of the read and write quota mapping. Through flow control and scheduling, you can achieve resource isolation of your applications and meet the quality of service (QoS) requirements. -The introduction of the resource control feature is a milestone for TiDB. It can divide a distributed database cluster into multiple logical units. Even if an individual unit overuses resources, it does not crowd out the resources needed by other units. +The TiDB resource control feature provides two layers of resource management capabilities: flow control capabilities at the TiDB layer and priority scheduling capabilities at the TiKV layer. The two capabilities are orthogonal and can be enabled separately or simultaneously. See the [Parameters for resource control](#parameters-for-resource-control) for details. + +- TiDB flow control: TiDB flow control uses the token bucket algorithm. The number of tokens consumed by read and write requests cannot exceed the number of tokens accumulated in the corresponding resource group bucket. If there are not enough tokens in the bucket, and the resource group does not specify the `BURSTABLE` option, the requests to the resource group will wait for the token bucket to backfill the tokens and retry. The retry may fail due to timeout. +- TiKV scheduling: If this feature is enabled, TiKV uses the value of `RU_PER_SEC` of each resource group to map the read and write requests of each resource group to their own priorities. Based on their own priorities, the storage layer uses the priority queue to schedule and process requests. + +The introduction of the resource control feature is a milestone for TiDB. It can divide a distributed database cluster into multiple logical units. Even if an individual unit overuses resources, it does not crowd out the resources needed by other units. + +## Scenarios for resource control This feature applies to the following scenarios: From 3b9915b22cccb6baf64daadf39301eb740d4bc82 Mon Sep 17 00:00:00 2001 From: xixirangrang Date: Mon, 6 Feb 2023 22:49:10 +0800 Subject: [PATCH 21/63] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Daniël van Eeden Co-authored-by: tiancaiamao --- information-schema/information-schema-processlist.md | 2 +- tidb-resource-control.md | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/information-schema/information-schema-processlist.md b/information-schema/information-schema-processlist.md index 510d056bdebf8..05724f5946b66 100644 --- a/information-schema/information-schema-processlist.md +++ b/information-schema/information-schema-processlist.md @@ -38,7 +38,7 @@ DESC processlist; | MEM | bigint(21) unsigned | YES | | NULL | | | DISK | bigint(21) unsigned | YES | | NULL | | | TxnStart | varchar(64) | NO | | | | -| RESOURCE_GROUP | varchar(32) | NO | | | | +| RESOURCE_GROUP | varchar(32) | NO | | | | +---------------------+---------------------+------+------+---------+-------+ 13 rows in set (0.00 sec) ``` diff --git a/tidb-resource-control.md b/tidb-resource-control.md index 4fe87a544a0f3..eb148612c79fb 100644 --- a/tidb-resource-control.md +++ b/tidb-resource-control.md @@ -9,7 +9,7 @@ summary: Learn how to use resource management to control and schedule applicatio > > This feature is experimental and its form and usage may change in subsequent versions. -Using the resource control feature, as a cluster administrator, you can define resource groups and limit the read and write quotas by resource groups. After you bind users to a resource group, the TiDB layer will perform flow control on the user's read and write requests according to the read and write quotas set by the bound resource group. Meanwhile, the TiKV layer will schedule the requests according to the priority of the read and write quota mapping. Through flow control and scheduling, you can achieve resource isolation of your applications and meet the quality of service (QoS) requirements. +Using the resource control feature, as a cluster administrator, you can define resource groups and limit the read and write quotas of resource groups. After you bind users to a resource group, the TiDB layer will perform flow control on the user's read and write requests according to the read and write quotas set by the bound resource group. Meanwhile, the TiKV layer will schedule the requests according to the priority of the read and write quota mapping. Through flow control and scheduling, you can achieve resource isolation of your applications and meet the quality of service (QoS) requirements. The TiDB resource control feature provides two layers of resource management capabilities: flow control capabilities at the TiDB layer and priority scheduling capabilities at the TiKV layer. The two capabilities are orthogonal and can be enabled separately or simultaneously. See the [Parameters for resource control](#parameters-for-resource-control) for details. @@ -31,7 +31,7 @@ In addition, the rational use of the resource control feature can reduce the num > **Note:** > -> This feature does not support [Serverless Tier clusters](/tidb-cloud/select-cluster-tier.md#serverless-tier-beta). +> This feature is not available on [Serverless Tier clusters](/tidb-cloud/select-cluster-tier.md#serverless-tier-beta). @@ -64,7 +64,7 @@ The resource control feature introduces two new global variables. > **Note:** > -> The parameter `resource_control.enabled` is disabled by default. It does not support dynamic modification. You need to contact the [PingCAP support team](/tidb-cloud/tidb-cloud-support.md) to enable it. You need to restart the TiKV instance for the modification to take effect. +> The parameter `resource_control.enabled` is disabled by default. It does not support dynamic modification. You need to contact the [PingCAP support](/tidb-cloud/tidb-cloud-support.md) to enable it. You need to restart the TiKV instance for the modification to take effect. From ee9415af538d50140a21b11b544c4048da553fdd Mon Sep 17 00:00:00 2001 From: xixirangrang <35301108+hfxsd@users.noreply.github.com> Date: Tue, 7 Feb 2023 09:25:16 +0800 Subject: [PATCH 22/63] Update TOC.md --- TOC.md | 1 + 1 file changed, 1 insertion(+) diff --git a/TOC.md b/TOC.md index 2c21e0512216f..56b317577f203 100644 --- a/TOC.md +++ b/TOC.md @@ -607,6 +607,7 @@ - [TiKV](/grafana-tikv-dashboard.md) - [TiFlash](/tiflash/monitor-tiflash.md) - [TiCDC](/ticdc/monitor-ticdc.md) + - [Resource Control](/grafana-resource-control-dashboard.md) - Secure - [Enable TLS Between TiDB Clients and Servers](/enable-tls-between-clients-and-servers.md) - [Enable TLS Between TiDB Components](/enable-tls-between-components.md) From 464d30ceeb9fad60360a62d771e1a87a63137f7a Mon Sep 17 00:00:00 2001 From: xixirangrang <35301108+hfxsd@users.noreply.github.com> Date: Tue, 7 Feb 2023 14:56:22 +0800 Subject: [PATCH 23/63] polished wording --- grafana-resource-control-dashboard.md | 46 +++++++------- .../information-schema-resource-groups.md | 6 +- .../sql-statement-alter-resource-group.md | 2 +- .../sql-statement-create-resource-group.md | 2 +- .../sql-statement-show-privileges.md | 2 +- tidb-resource-control.md | 62 ++++++++++--------- 6 files changed, 63 insertions(+), 57 deletions(-) diff --git a/grafana-resource-control-dashboard.md b/grafana-resource-control-dashboard.md index 16dd982daaf43..9b36744751250 100644 --- a/grafana-resource-control-dashboard.md +++ b/grafana-resource-control-dashboard.md @@ -11,26 +11,26 @@ The Grafana dashboard is divided into a series of sub dashboards which include O You can get an overview of the resource control status from the PD dashboard, where the key metrics are displayed. This document provides a detailed description of these key metrics. -The following is the description of Resource Control Dashboard metrics items. - -## Request Unit - -- RU: the [Request Unit](/tidb-resource-control.md#what-is-request-unit-ru) consumption information of each Resource Group is calculated in real time. `total` is the sum of the Request Units consumed by all Resource Groups. The Request Unit consumption of each Resource Group should be equal to the sum of its read consumption (Read Request Unit) and write consumption (Write Request Unit). -- RU Per Query: the average number of Request Units consumed by each SQL statement per second is obtained by dividing the above Request Unit by the number of SQL statements executed per second. -- RRU: the Read Request Unit consumption information of each Resource Group is calculated in real time. `total` is the sum of the Read Request Units consumed by all Resource Groups. -- RRU Per Query: the average number of Read Request Units consumed by each SQL statement per second is obtained by dividing the above Read Request Unit by the number of SQL statements executed per second. -- WRU: the Write Request Unit consumption information of each Resource Group is calculated in real time. `total` is the sum of the Write Request Units consumed by all Resource Groups. -- WRU Per Query: the average number of Write Request Units consumed by each SQL statement per second is obtained by dividing the above Write Request Unit by the number of SQL statements executed per second. - -## Resource - -- KV Request Count: the number of KV requests is calculated in real time for each Resource Group. They are divided into read and write types. `total` is the sum of the KV requests involved by all Resource Groups. -- KV Request Count Per Query: the average number of read and write KV requests by each SQL statement per second is obtained by dividing the above KV Request Count by the number of SQL statements executed per second. -- Bytes Read: the amount of data read is calculated in real time for each Resource Group. `total` is the sum of the data read by all Resource Groups. -- Bytes Read Per Query: the average amount of data read by each SQL statement per second is obtained by dividing the above Bytes Read by the number of SQL statements executed per second. -- Bytes Written: the amount of data written is calculated in real time for each Resource Group. `total` is the sum of the data written by all Resource Groups. -- Bytes Written Per Query: the average amount of data written by each SQL statement per second is obtained by dividing the above Bytes Written by the number of SQL statements executed per second. -- KV CPU Time: the KV layer CPU time consumed is calculated in real time for each Resource Group. `total` is the sum of the KV layer CPU time consumed by all Resource Groups. -- KV CPU Time Per Query: the average KV layer CPU time consumed by each SQL statement per second is obtained by dividing the above KV CPU Time by the number of SQL statements executed per second. -- SQL CPU Time: the SQL layer CPU time consumed is calculated in real time for each Resource Group. `total` is the sum of the SQL layer CPU time consumed by all Resource Groups. -- SQL CPU Time Per Query: the average SQL layer CPU time consumed by each SQL statement per second is obtained by dividing the above SQL CPU Time by the number of SQL statements executed per second. +This document describes some key monitoring metrics displayed on the Resource Control Dashboard. + +## Metrics about Request Unit + +- RU: the [Request Unit (RU)](/tidb-resource-control.md#what-is-request-unit-ru) consumption information of each resource group is calculated in real time. `total` is the sum of the Request Units consumed by all Resource Groups. The Request Unit consumption of each resource group should be equal to the sum of its read consumption (Read Request Unit) and write consumption (Write Request Unit). +- RU Per Query: the average number of Request Units consumed by each SQL statement per second. It is obtained by dividing the above Request Unit by the number of SQL statements executed per second. +- RRU: the Read Request Unit consumption information of each resource group is calculated in real time. `total` is the sum of the Read Request Units consumed by all Resource Groups. +- RRU Per Query: the average number of Read Request Units consumed by each SQL statement per second. It is obtained by dividing the above Read Request Unit by the number of SQL statements executed per second. +- WRU: the Write Request Unit consumption information of each resource group is calculated in real time. `total` is the sum of the Write Request Units consumed by all Resource Groups. +- WRU Per Query: the average number of Write Request Units consumed by each SQL statement per second. It is obtained by dividing the above Write Request Unit by the number of SQL statements executed per second. + +## Metrics about resources + +- KV Request Count: the number of KV requests is calculated in real time for each resource group. They are divided into read and write types. `total` is the sum of the KV requests involved by all Resource Groups. +- KV Request Count Per Query: the average number of read and write KV requests by each SQL statement per second. It is obtained by dividing the above KV Request Count by the number of SQL statements executed per second. +- Bytes Read: the amount of data read is calculated in real time for each resource group. `total` is the sum of the data read by all Resource Groups. +- Bytes Read Per Query: the average amount of data read by each SQL statement per second. It is obtained by dividing the above Bytes Read by the number of SQL statements executed per second. +- Bytes Written: the amount of data written is calculated in real time for each resource group. `total` is the sum of the data written by all Resource Groups. +- Bytes Written Per Query: the average amount of data written by each SQL statement per second. It is obtained by dividing the above Bytes Written by the number of SQL statements executed per second. +- KV CPU Time: the KV layer CPU time consumed is calculated in real time for each resource group. `total` is the sum of the KV layer CPU time consumed by all Resource Groups. +- KV CPU Time Per Query: the average KV layer CPU time consumed by each SQL statement per second. It is obtained by dividing the above KV CPU Time by the number of SQL statements executed per second. +- SQL CPU Time: the SQL layer CPU time consumed is calculated in real time for each resource group. `total` is the sum of the SQL layer CPU time consumed by all Resource Groups. +- SQL CPU Time Per Query: the average SQL layer CPU time consumed by each SQL statement per second. It is obtained by dividing the above SQL CPU Time by the number of SQL statements executed per second. diff --git a/information-schema/information-schema-resource-groups.md b/information-schema/information-schema-resource-groups.md index 165a09ccae692..72f404333020e 100644 --- a/information-schema/information-schema-resource-groups.md +++ b/information-schema/information-schema-resource-groups.md @@ -52,6 +52,6 @@ mysql> SELECT * FROM information_schema.resource_groups WHERE NAME = 'rg1'; The descriptions of the columns in the `RESOURCE_GROUPS` table are as follows: * `NAME`: the name of the resource group. -* `RU_PER_SEC`:the backfilling speed of the resource group in [Request Unit (RU)](/tidb-resource-control.md#what-is-request-unit-ru)/second. -* `RU_TOKENS`: the number of tokens left in the resource group token bucket, and 1 token is an RU. -* `BURSTABLE`: whether to allow this resource group to overuse the remaining system resources. +* `RU_PER_SEC`:the backfilling speed of the resource group. The unit is RU/second, in which RU means [Request Unit](/tidb-resource-control.md#what-is-request-unit-ru). +* `RU_TOKENS`: the number of tokens left in the resource group token bucket, and 1 token is 1 RU. +* `BURSTABLE`: whether to allow the resource group to overuse the available system resources. diff --git a/sql-statements/sql-statement-alter-resource-group.md b/sql-statements/sql-statement-alter-resource-group.md index 2bd9ae3e18457..98f448672cf19 100644 --- a/sql-statements/sql-statement-alter-resource-group.md +++ b/sql-statements/sql-statement-alter-resource-group.md @@ -34,7 +34,7 @@ TiDB supports the following `DirectResourceGroupOption`, where [Request Unit (RU | Option | Description | Example | |---------------|-------------------------------------|------------------------| -|`RU_PER_SEC` | Rate of RU filling per second |`RU_PER_SEC = 500` indicates that this resource group is backfilled with 500 RU per second | +|`RU_PER_SEC` | Rate of RU filling per second |`RU_PER_SEC = 500` indicates that this resource group is backfilled with 500 RUs per second | If the `BURSTABLE` attribute is set, the corresponding resource group allows the available system resources to be used exceeding the quota. diff --git a/sql-statements/sql-statement-create-resource-group.md b/sql-statements/sql-statement-create-resource-group.md index 277e83670eff3..1620a7436ee53 100644 --- a/sql-statements/sql-statement-create-resource-group.md +++ b/sql-statements/sql-statement-create-resource-group.md @@ -36,7 +36,7 @@ TiDB supports the following `DirectResourceGroupOption`, where [Request Unit (RU | Option | Description | Example | |---------------|-------------------------------------|------------------------| -|`RU_PER_SEC` | Rate of RU filling per second |`RU_PER_SEC = 500` indicates that this resource group is backfilled with 500 RU per second | +|`RU_PER_SEC` | Rate of RU filling per second |`RU_PER_SEC = 500` indicates that this resource group is backfilled with 500 RUs per second | If the `BURSTABLE` attribute is set, the corresponding resource group allows the system resources to be used exceeding the quota. diff --git a/sql-statements/sql-statement-show-privileges.md b/sql-statements/sql-statement-show-privileges.md index 0b640608eb756..986e1260b71fe 100644 --- a/sql-statements/sql-statement-show-privileges.md +++ b/sql-statements/sql-statement-show-privileges.md @@ -16,7 +16,7 @@ This statement shows a list of assignable privileges in TiDB. It is a static lis ## Examples -``` +```sql mysql> show privileges; +---------------------------------+---------------------------------------+-------------------------------------------------------+ | Privilege | Context | Comment | diff --git a/tidb-resource-control.md b/tidb-resource-control.md index eb148612c79fb..708672189028b 100644 --- a/tidb-resource-control.md +++ b/tidb-resource-control.md @@ -1,6 +1,6 @@ --- title: Use Resource Control to Achieve Resource Isolation -summary: Learn how to use resource management to control and schedule application resource consumption. +summary: Learn how to use the resource control feature to control and schedule application resources. --- # Use Resource Control to Achieve Resource Isolation @@ -11,13 +11,21 @@ summary: Learn how to use resource management to control and schedule applicatio Using the resource control feature, as a cluster administrator, you can define resource groups and limit the read and write quotas of resource groups. After you bind users to a resource group, the TiDB layer will perform flow control on the user's read and write requests according to the read and write quotas set by the bound resource group. Meanwhile, the TiKV layer will schedule the requests according to the priority of the read and write quota mapping. Through flow control and scheduling, you can achieve resource isolation of your applications and meet the quality of service (QoS) requirements. -The TiDB resource control feature provides two layers of resource management capabilities: flow control capabilities at the TiDB layer and priority scheduling capabilities at the TiKV layer. The two capabilities are orthogonal and can be enabled separately or simultaneously. See the [Parameters for resource control](#parameters-for-resource-control) for details. +The TiDB resource control feature provides two layers of resource management capabilities: the flow control capability at the TiDB layer and the priority scheduling capability at the TiKV layer. The two capabilities are orthogonal and can be enabled separately or simultaneously. See the [Parameters for resource control](#parameters-for-resource-control) for details. -- TiDB flow control: TiDB flow control uses the token bucket algorithm. The number of tokens consumed by read and write requests cannot exceed the number of tokens accumulated in the corresponding resource group bucket. If there are not enough tokens in the bucket, and the resource group does not specify the `BURSTABLE` option, the requests to the resource group will wait for the token bucket to backfill the tokens and retry. The retry may fail due to timeout. -- TiKV scheduling: If this feature is enabled, TiKV uses the value of `RU_PER_SEC` of each resource group to map the read and write requests of each resource group to their own priorities. Based on their own priorities, the storage layer uses the priority queue to schedule and process requests. +- TiDB flow control: TiDB flow control uses the token bucket algorithm (`RU_TOKENS`). The number of tokens consumed by read and write requests cannot exceed the number of tokens accumulated in the corresponding resource group bucket. If there are not enough tokens in the bucket, and the resource group does not specify the `BURSTABLE` option, the requests to the resource group will wait for the token bucket to backfill the tokens and retry. The retry may fail due to timeout. +- TiKV scheduling: If [`resource_control.enabled`](/tikv-configuration-file.md#resource_control) is enabled, TiKV uses the value of `RU_PER_SEC` of each resource group to map the read and write requests of each resource group to their own priorities. Based on their own priorities, the storage layer uses the priority queue to schedule and process requests. The introduction of the resource control feature is a milestone for TiDB. It can divide a distributed database cluster into multiple logical units. Even if an individual unit overuses resources, it does not crowd out the resources needed by other units. + + +> **Note:** +> +> This feature is not available on [Serverless Tier clusters](/tidb-cloud/select-cluster-tier.md#serverless-tier-beta). + + + ## Scenarios for resource control This feature applies to the following scenarios: @@ -27,31 +35,23 @@ This feature applies to the following scenarios: In addition, the rational use of the resource control feature can reduce the number of clusters, ease the difficulty of operation and maintenance, and save management costs. - - -> **Note:** -> -> This feature is not available on [Serverless Tier clusters](/tidb-cloud/select-cluster-tier.md#serverless-tier-beta). - - - ## What is Request Unit (RU) -Request Unit (RU) is TiDB's unified abstraction unit for CPU, IO and other system resources, which currently includes CPU, IOPS and IO bandwidth metrics. The consumption of these three metrics is represented by the RU unit according to a certain ratio. +Request Unit (RU) is TiDB's unified abstraction unit for system resources, which currently includes CPU, IOPS and IO bandwidth metrics. The consumption of these three metrics is represented by RU according to a certain ratio. The following table shows the consumption of TiKV storage layer CPU and IO resources by user requests and the corresponding RU weights. -| Resource | RU Weight | -|:----------|:------| -| CPU | 1 RU / Milliseconds | -| Read IO | 1 RU / MiB | -| Write IO | 5 RU / MiB | -| Basic overhead of a read request | 1 RU | -| Basic overhead of a write request | 3 RU | +| Resource | RU Weight | +|:----------------|:-----------------| +| CPU | 1 RU/millisecond | +| Read IO | 1/64 RU/KB | +| Write IO | 1 RU/KB | +| Basic overhead of a read request | 0.25 RU | +| Basic overhead of a write request | 1.5 RU | -Based on the above table, assuming that the TiKV time consumed by a resource group is `c` milliseconds, `r1` requests that read `r2` MiB data, and `w1` write requests that write `w2` MiB data, then the formula for the total RUs consumed by the resource group is as follows: +Based on the above table, assuming that the TiKV time consumed by a resource group is `c` milliseconds, `r1` requests that read `r2` KB data, and `w1` write requests that write `w2` KB data, then the formula for the total RUs consumed by the resource group is as follows: -c + (r1 + r2) + (3 * w1 + 5 * w2) +`c` + (`r1` \* 0.25 + `r2`/64) + (1.5 * `w1` + `w2`) ## Parameters for resource control @@ -64,7 +64,7 @@ The resource control feature introduces two new global variables. > **Note:** > -> The parameter `resource_control.enabled` is disabled by default. It does not support dynamic modification. You need to contact the [PingCAP support](/tidb-cloud/tidb-cloud-support.md) to enable it. You need to restart the TiKV instance for the modification to take effect. +> The parameter `resource_control.enabled` is disabled by default. It does not support dynamic modification. You need to contact the [PingCAP support team](/tidb-cloud/tidb-cloud-support.md) to enable it. @@ -92,29 +92,35 @@ You can delete a resource group by using [`DROP RESOURCE GROUP`](/sql-statements ### Step 1. Enable the resource control feature -Enable flow control for the resource group. +Enable the resource control feature. ```sql SET GLOBAL tidb_enable_resource_control = 'ON'; ``` + + +In TiKV, set the parameter [`resource_control.enabled`](/tikv-configuration-file.md#resource_control) to `true`. + + + -In TiKV, set the parameter `resource_control.enabled` to `true`. The parameter `resource_control.enabled` is disabled by default. You need to contact the [PingCAP support team](/tidb-cloud/tidb-cloud-support.md) to enable it. +In TiKV, set the parameter [`resource_control.enabled`](https://docs.pingcap.com/tidb/stable/tikv-configuration-file#resource_control) to `true`. The parameter `resource_control.enabled` is disabled by default. You need to contact the [PingCAP support team](/tidb-cloud/tidb-cloud-support.md) to enable it. - + ### Step 2. Create a resource group, and then bind users to it The following is an example of how to create a resource group and bind users to it. -1. Create a resource group `rg1`. The RU backfill rate is 500 RU per second and allows applications in this resource group to overrun resources. +1. Create a resource group `rg1`. The RU backfill rate is 500 RUs per second and allows applications in this resource group to overrun resources. ```sql CREATE RESOURCE GROUP IF NOT EXISTS rg1 RU_PER_SEC = 500 BURSTABLE; ``` -2. Create a resource group `rg2`. The RU backfill rate is 500 RU per second and does not allow applications in this resource group to overrun resources. +2. Create a resource group `rg2`. The RU backfill rate is 500 RUs per second and does not allow applications in this resource group to overrun resources. ```sql CREATE RESOURCE GROUP IF NOT EXISTS rg2 RU_PER_SEC = 600; From 3fa096ffed0c9c53ee6556b11d4ea7912d8d61c5 Mon Sep 17 00:00:00 2001 From: xixirangrang <35301108+hfxsd@users.noreply.github.com> Date: Tue, 7 Feb 2023 15:40:43 +0800 Subject: [PATCH 24/63] Update tidb-resource-control.md --- tidb-resource-control.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tidb-resource-control.md b/tidb-resource-control.md index 708672189028b..cccf35eb732b4 100644 --- a/tidb-resource-control.md +++ b/tidb-resource-control.md @@ -142,6 +142,14 @@ If the resource group corresponds to a request with insufficient quota, the clie ## Monitoring and charts + + +> **Note:** +> +> This section is not applicable to TiDB Cloud. + + + TiDB regularly collects runtime information about resource control and provides visual charts of the metrics in Grafana's **TiDB** > **Resource Control** panel. The metrics are detailed in the **Resource Control** section of [TiDB Important Monitoring Metrics](/grafana-tidb-dashboard.md). ## Tool Compatibility From e522fcd6d60cf5d39e266a7b4e705d8eda601c02 Mon Sep 17 00:00:00 2001 From: xixirangrang <35301108+hfxsd@users.noreply.github.com> Date: Tue, 7 Feb 2023 16:31:41 +0800 Subject: [PATCH 25/63] Update information-schema-resource-groups.md --- information-schema/information-schema-resource-groups.md | 1 + 1 file changed, 1 insertion(+) diff --git a/information-schema/information-schema-resource-groups.md b/information-schema/information-schema-resource-groups.md index 72f404333020e..b52fd4281db88 100644 --- a/information-schema/information-schema-resource-groups.md +++ b/information-schema/information-schema-resource-groups.md @@ -48,6 +48,7 @@ mysql> SELECT * FROM information_schema.resource_groups WHERE NAME = 'rg1'; +------+------------+-----------+-----------+ | rg1 | 1000 | 100000 | NO | +------+------------+-----------+-----------+ +``` The descriptions of the columns in the `RESOURCE_GROUPS` table are as follows: From d93d8a74f4e5519d9ed8a0b0976aa20a236b5fdc Mon Sep 17 00:00:00 2001 From: xixirangrang Date: Tue, 7 Feb 2023 18:37:09 +0800 Subject: [PATCH 26/63] Apply suggestions from code review Co-authored-by: BornChanger <97348524+BornChanger@users.noreply.github.com> Co-authored-by: ShuNing --- .../sql-statement-create-resource-group.md | 4 ++-- .../sql-statement-drop-resource-group.md | 2 +- tidb-resource-control.md | 18 +++++++++--------- tikv-configuration-file.md | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/sql-statements/sql-statement-create-resource-group.md b/sql-statements/sql-statement-create-resource-group.md index 1620a7436ee53..1a22181d22d88 100644 --- a/sql-statements/sql-statement-create-resource-group.md +++ b/sql-statements/sql-statement-create-resource-group.md @@ -5,7 +5,7 @@ summary: Learn the usage of CREATE RESOURCE GROUP in TiDB. # CREATE RESOURCE GROUP -You can use the `CREATE RESOURCE GROUP` statement to create a resource group in the currently selected database. +You can use the `CREATE RESOURCE GROUP` statement to create a resource group. ## Synopsis @@ -56,7 +56,7 @@ mysql> CREATE RESOURCE GROUP IF NOT EXISTS rg1 -> BURSTABLE; Query OK, 0 rows affected (0.08 sec) mysql> CREATE RESOURCE GROUP IF NOT EXISTS rg2 - -> RU_PER_SEC = 200 + -> RU_PER_SEC = 200; Query OK, 0 rows affected (0.08 sec) mysql> SELECT * FROM information_schema.resource_groups WHERE NAME ='rg1' or NAME = 'rg2'; +------+-------------+-----------+-----------+ diff --git a/sql-statements/sql-statement-drop-resource-group.md b/sql-statements/sql-statement-drop-resource-group.md index ae22d67263394..605d0c0accf1c 100644 --- a/sql-statements/sql-statement-drop-resource-group.md +++ b/sql-statements/sql-statement-drop-resource-group.md @@ -5,7 +5,7 @@ summary: Learn the usage of DROP RESOURCE GROUP in TiDB. # DROP RESOURCE GROUP -You can use the `DROP RESOURCE GROUP` statement to drop a resource group in the currently selected database. +You can use the `DROP RESOURCE GROUP` statement to drop a resource group. ## Synopsis diff --git a/tidb-resource-control.md b/tidb-resource-control.md index cccf35eb732b4..c782747323d5e 100644 --- a/tidb-resource-control.md +++ b/tidb-resource-control.md @@ -14,7 +14,7 @@ Using the resource control feature, as a cluster administrator, you can define r The TiDB resource control feature provides two layers of resource management capabilities: the flow control capability at the TiDB layer and the priority scheduling capability at the TiKV layer. The two capabilities are orthogonal and can be enabled separately or simultaneously. See the [Parameters for resource control](#parameters-for-resource-control) for details. - TiDB flow control: TiDB flow control uses the token bucket algorithm (`RU_TOKENS`). The number of tokens consumed by read and write requests cannot exceed the number of tokens accumulated in the corresponding resource group bucket. If there are not enough tokens in the bucket, and the resource group does not specify the `BURSTABLE` option, the requests to the resource group will wait for the token bucket to backfill the tokens and retry. The retry may fail due to timeout. -- TiKV scheduling: If [`resource_control.enabled`](/tikv-configuration-file.md#resource_control) is enabled, TiKV uses the value of `RU_PER_SEC` of each resource group to map the read and write requests of each resource group to their own priorities. Based on their own priorities, the storage layer uses the priority queue to schedule and process requests. +- TiKV scheduling: If [`resource-control.enabled`](/tikv-configuration-file.md#resource_control) is enabled, TiKV uses the value of `RU_PER_SEC` of each resource group to map the read and write requests of each resource group to their own priorities. Based on their own priorities, the storage layer uses the priority queue to schedule and process requests. The introduction of the resource control feature is a milestone for TiDB. It can divide a distributed database cluster into multiple logical units. Even if an individual unit overuses resources, it does not crowd out the resources needed by other units. @@ -44,7 +44,7 @@ The following table shows the consumption of TiKV storage layer CPU and IO resou | Resource | RU Weight | |:----------------|:-----------------| | CPU | 1 RU/millisecond | -| Read IO | 1/64 RU/KB | +| Read IO | (1/64) RU/KB | | Write IO | 1 RU/KB | | Basic overhead of a read request | 0.25 RU | | Basic overhead of a write request | 1.5 RU | @@ -58,22 +58,22 @@ Based on the above table, assuming that the TiKV time consumed by a resource gro The resource control feature introduces two new global variables. * TiDB: you can use the system variable [`tidb_enable_resource_control`](/system-variables.md#tidb-tidb_enable_resource_control-new-in-v660) to control whether to enable flow control for a resource group. -* TiKV: you can use the parameter [`resource_control.enabled`](/tikv-configuration-file.md#resource_control) to control whether to use request scheduling based on resource group quotas. +* TiKV: you can use the parameter [`resource-control.enabled`](/tikv-configuration-file.md#resource_control) to control whether to use request scheduling based on resource group quotas. > **Note:** > -> The parameter `resource_control.enabled` is disabled by default. It does not support dynamic modification. You need to contact the [PingCAP support team](/tidb-cloud/tidb-cloud-support.md) to enable it. +> The parameter `resource_control.enabled` is disabled by default. It does not support dynamic modification. You need to contact the [PingCAP support team](/tidb-cloud/tidb-cloud-support.md) to enable it for TiDB Cloud Dedicated Tier clusters. The results of the combinations of these two parameters are shown in the following table. -| `resource_control.enabled` | `tidb_enable_resource_control`= ON | `tidb_enable_resource_control`= OFF | +| `resource-control.enabled` | `tidb_enable_resource_control`= ON | `tidb_enable_resource_control`= OFF | |:----------------------------|:-------------------------------------|:-------------------------------------| -| `resource_control.enabled`= true | Flow control and scheduling (recommended) | Invalid combination | -| `resource_control.enabled`= false | Only flow control | The feature is disabled. | +| `resource-control.enabled`= true | Flow control and scheduling (recommended) | Invalid combination | +| `resource-control.enabled`= false | Only flow control | The feature is disabled. | ## How to use resource control @@ -100,13 +100,13 @@ SET GLOBAL tidb_enable_resource_control = 'ON'; -In TiKV, set the parameter [`resource_control.enabled`](/tikv-configuration-file.md#resource_control) to `true`. +In TiKV, set the parameter [`resource-control.enabled`](/tikv-configuration-file.md#resource_control) to `true`. -In TiKV, set the parameter [`resource_control.enabled`](https://docs.pingcap.com/tidb/stable/tikv-configuration-file#resource_control) to `true`. The parameter `resource_control.enabled` is disabled by default. You need to contact the [PingCAP support team](/tidb-cloud/tidb-cloud-support.md) to enable it. +In TiKV, set the parameter [`resource_control.enabled`](https://docs.pingcap.com/tidb/stable/tikv-configuration-file#resource_control) to `true`. The parameter `resource-control.enabled` is disabled by default. You need to contact the [PingCAP support team](/tidb-cloud/tidb-cloud-support.md) to enable it. diff --git a/tikv-configuration-file.md b/tikv-configuration-file.md index 7ef7f2429011f..2215bd7e2c719 100644 --- a/tikv-configuration-file.md +++ b/tikv-configuration-file.md @@ -2156,7 +2156,7 @@ To reduce write latency, TiKV periodically fetches and caches a batch of timesta + In a default TSO physical time update interval (`50ms`), PD provides at most 262144 TSOs. When requested TSOs exceed this number, PD provides no more TSOs. This configuration item is used to avoid exhausting TSOs and the reverse impact of TSO exhaustion on other businesses. If you increase the value of this configuration item to improve high availability, you need to decrease the value of [`tso-update-physical-interval`](/pd-configuration-file.md#tso-update-physical-interval) at the same time to get enough TSOs. + Default value: `8192` -## resource_control +## resource-control Configuration items related to resource control related to the TiKV storage layer. From 3c6e57bfdf10cdddce8ffa63e667008b85d2fd93 Mon Sep 17 00:00:00 2001 From: xixirangrang Date: Tue, 7 Feb 2023 21:55:51 +0800 Subject: [PATCH 27/63] Apply suggestions from code review --- tidb-resource-control.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tidb-resource-control.md b/tidb-resource-control.md index c782747323d5e..c63441c659203 100644 --- a/tidb-resource-control.md +++ b/tidb-resource-control.md @@ -64,7 +64,7 @@ The resource control feature introduces two new global variables. > **Note:** > -> The parameter `resource_control.enabled` is disabled by default. It does not support dynamic modification. You need to contact the [PingCAP support team](/tidb-cloud/tidb-cloud-support.md) to enable it for TiDB Cloud Dedicated Tier clusters. +> The parameter `resource-control.enabled` is disabled by default. It does not support dynamic modification. You need to contact the [PingCAP support team](/tidb-cloud/tidb-cloud-support.md) to enable it for TiDB Cloud Dedicated Tier clusters. @@ -106,7 +106,7 @@ In TiKV, set the parameter [`resource-control.enabled`](/tikv-configuration-file -In TiKV, set the parameter [`resource_control.enabled`](https://docs.pingcap.com/tidb/stable/tikv-configuration-file#resource_control) to `true`. The parameter `resource-control.enabled` is disabled by default. You need to contact the [PingCAP support team](/tidb-cloud/tidb-cloud-support.md) to enable it. +In TiKV, set the parameter [`resource-control.enabled`](https://docs.pingcap.com/tidb/stable/tikv-configuration-file#resource_control) to `true`. The parameter `resource-control.enabled` is disabled by default. You need to contact the [PingCAP support team](/tidb-cloud/tidb-cloud-support.md) to enable it. From e897300851254cea88fa3dbbaf96d58975fb6748 Mon Sep 17 00:00:00 2001 From: xixirangrang Date: Tue, 7 Feb 2023 21:59:13 +0800 Subject: [PATCH 28/63] Apply suggestions from code review --- tidb-resource-control.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tidb-resource-control.md b/tidb-resource-control.md index c63441c659203..9a6d1f1b69eb5 100644 --- a/tidb-resource-control.md +++ b/tidb-resource-control.md @@ -14,7 +14,7 @@ Using the resource control feature, as a cluster administrator, you can define r The TiDB resource control feature provides two layers of resource management capabilities: the flow control capability at the TiDB layer and the priority scheduling capability at the TiKV layer. The two capabilities are orthogonal and can be enabled separately or simultaneously. See the [Parameters for resource control](#parameters-for-resource-control) for details. - TiDB flow control: TiDB flow control uses the token bucket algorithm (`RU_TOKENS`). The number of tokens consumed by read and write requests cannot exceed the number of tokens accumulated in the corresponding resource group bucket. If there are not enough tokens in the bucket, and the resource group does not specify the `BURSTABLE` option, the requests to the resource group will wait for the token bucket to backfill the tokens and retry. The retry may fail due to timeout. -- TiKV scheduling: If [`resource-control.enabled`](/tikv-configuration-file.md#resource_control) is enabled, TiKV uses the value of `RU_PER_SEC` of each resource group to map the read and write requests of each resource group to their own priorities. Based on their own priorities, the storage layer uses the priority queue to schedule and process requests. +- TiKV scheduling: If [`resource-control.enabled`](/tikv-configuration-file.md#resource-control) is enabled, TiKV uses the value of `RU_PER_SEC` of each resource group to map the read and write requests of each resource group to their own priorities. Based on their own priorities, the storage layer uses the priority queue to schedule and process requests. The introduction of the resource control feature is a milestone for TiDB. It can divide a distributed database cluster into multiple logical units. Even if an individual unit overuses resources, it does not crowd out the resources needed by other units. @@ -58,7 +58,7 @@ Based on the above table, assuming that the TiKV time consumed by a resource gro The resource control feature introduces two new global variables. * TiDB: you can use the system variable [`tidb_enable_resource_control`](/system-variables.md#tidb-tidb_enable_resource_control-new-in-v660) to control whether to enable flow control for a resource group. -* TiKV: you can use the parameter [`resource-control.enabled`](/tikv-configuration-file.md#resource_control) to control whether to use request scheduling based on resource group quotas. +* TiKV: you can use the parameter [`resource-control.enabled`](/tikv-configuration-file.md#resource-control) to control whether to use request scheduling based on resource group quotas. @@ -100,7 +100,7 @@ SET GLOBAL tidb_enable_resource_control = 'ON'; -In TiKV, set the parameter [`resource-control.enabled`](/tikv-configuration-file.md#resource_control) to `true`. +In TiKV, set the parameter [`resource-control.enabled`](/tikv-configuration-file.md#resource-control) to `true`. From 7c73827ff8bc2cf2e7faa811751764de0d1e6386 Mon Sep 17 00:00:00 2001 From: xixirangrang Date: Wed, 8 Feb 2023 09:10:46 +0800 Subject: [PATCH 29/63] Update system-variables.md --- system-variables.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system-variables.md b/system-variables.md index 21b16b5a85e2a..b6da45409bd1b 100644 --- a/system-variables.md +++ b/system-variables.md @@ -1809,7 +1809,7 @@ MPP is a distributed computing framework provided by the TiFlash engine, which a - Persists to cluster: Yes - Default value: `OFF` - Type: Boolean -- This variable is a switch for [the resource control feature](/tidb-resource-control.md). When this variable is set to `ON`, the cluster supports resource isolation of applications by resource group. +- This variable is a switch for [the resource control feature](/tidb-resource-control.md). When this variable is set to `ON`, the TiDB cluster supports resource isolation of applications based on resource groups. ### tidb_enable_reuse_chunk New in v6.4.0 From 6804d8c5043c11f213ce3c8530f53340802918c8 Mon Sep 17 00:00:00 2001 From: xixirangrang Date: Wed, 8 Feb 2023 09:17:52 +0800 Subject: [PATCH 30/63] Update tikv-configuration-file.md --- tikv-configuration-file.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tikv-configuration-file.md b/tikv-configuration-file.md index 2215bd7e2c719..4073a3d3134c7 100644 --- a/tikv-configuration-file.md +++ b/tikv-configuration-file.md @@ -2162,6 +2162,6 @@ Configuration items related to resource control related to the TiKV storage laye ### `enabled` New in v6.6.0 -+ Whether to support prioritized scheduling for user foreground read/write requests according to the corresponding resource group quota. For information about TiDB resource groups and resource control, see [TiDB resource control](/tidb-resource-control.md) -+ It is only meaningful to enable this configuration item if [`tidb_enable_resource_control](/system-variables.md#tidb_enable_resource_control-new-in-v660) is enabled on TiDB side. When it is enabled, TiKV will use the priority queue to schedule the queued requests for user foreground read/write requests. The priority of scheduling is inversely related to the amount of resources already consumed by the resource group where the request is located, and positively related to the quota of the corresponding resource group. -+ Default value: `false`, which means to disable scheduling based on resource group quotas. \ No newline at end of file ++ Whether to support scheduling for user foreground read/write requests according to Request Unit (RU) of the corresponding resource group. For information about TiDB resource groups and resource control, see [TiDB resource control](/tidb-resource-control.md). ++ It is only meaningful to enable this configuration item if [`tidb_enable_resource_control](/system-variables.md#tidb_enable_resource_control-new-in-v660) is enabled on TiDB. When it is enabled, TiKV will use the priority queue to schedule the queued requests for user foreground read/write requests. The priority of scheduling is inversely related to the amount of resources already consumed by the resource group where the request is located, and positively related to the quota of the corresponding resource group. ++ Default value: `false`, which means to disable scheduling based on the RU of the resource group. \ No newline at end of file From 0aec93b27fefc83ee84f779d90eff8000f5bd0d4 Mon Sep 17 00:00:00 2001 From: xixirangrang Date: Wed, 8 Feb 2023 09:39:26 +0800 Subject: [PATCH 31/63] Update tidb-resource-control.md --- tidb-resource-control.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tidb-resource-control.md b/tidb-resource-control.md index 9a6d1f1b69eb5..a2dd15a0fbeeb 100644 --- a/tidb-resource-control.md +++ b/tidb-resource-control.md @@ -28,10 +28,12 @@ The introduction of the resource control feature is a milestone for TiDB. It can ## Scenarios for resource control -This feature applies to the following scenarios: + With this feature, you can: -- You can combine multiple small and medium-sized applications from different systems into one TiDB cluster. If the load of an individual application grows larger, it does not affect the normal operation of other businesses. When the system load is low, busy applications can still be allocated the required system resources even if they exceed the set read and write quotas, so as to achieve the maximum utilization of resources. -- You can choose to combine all test environments into a single cluster, or group the batch tasks that consume more resources into a single resource group. It can improve hardware utilization and reduce operating costs while ensuring that critical applications can still get the necessary resources. + - Combine multiple small and medium-sized applications from different systems into a single TiDB cluster. When the workload of an application grows larger, it does not affect the normal operation of other applications. When the system workload is low, busy applications can still be allocated the required system resources even if they exceed the set read and write quotas, so as to achieve the maximum utilization of resources. + - Choose to combine all test environments into a single TiDB cluster, or group the batch tasks that consume more resources into a single resource group. It can improve hardware utilization and reduce operating costs while ensuring that critical applications can always get the necessary resources. + + In addition, the rational use of the resource control feature can reduce the number of clusters, ease the difficulty of operation and maintenance, and save management costs. In addition, the rational use of the resource control feature can reduce the number of clusters, ease the difficulty of operation and maintenance, and save management costs. From 63381ba7e829ffe59ecc360a7994a2cdf59db4ad Mon Sep 17 00:00:00 2001 From: xixirangrang <35301108+hfxsd@users.noreply.github.com> Date: Wed, 8 Feb 2023 15:53:55 +0800 Subject: [PATCH 32/63] sync cn commits --- .../information-schema-resource-groups.md | 12 +++++----- mysql-compatibility.md | 8 +++++++ .../sql-statement-alter-resource-group.md | 22 +++++++++---------- .../sql-statement-create-resource-group.md | 14 ++++++------ .../sql-statement-drop-resource-group.md | 12 +++++----- tidb-resource-control.md | 14 ++++++------ 6 files changed, 44 insertions(+), 38 deletions(-) diff --git a/information-schema/information-schema-resource-groups.md b/information-schema/information-schema-resource-groups.md index b52fd4281db88..045f126fe8249 100644 --- a/information-schema/information-schema-resource-groups.md +++ b/information-schema/information-schema-resource-groups.md @@ -22,7 +22,6 @@ DESC resource_groups; +------------+-------------+------+------+---------+-------+ | NAME | varchar(32) | NO | | NULL | | | RU_PER_SEC | bigint(21) | YES | | NULL | | -| RU_TOKENS | bigint(21) | YES | | NULL | | | BURSTABLE | varchar(3) | YES | | NULL | | +------------+-------------+------+------+---------+-------+ 4 rows in set (0.00 sec) @@ -43,16 +42,15 @@ mysql> SHOW CREATE RESOURCE GROUP rg1; -- Displays the definition of the rg1 res +----------------+---------------------------------------------+ 1 row in set (0.00 sec) mysql> SELECT * FROM information_schema.resource_groups WHERE NAME = 'rg1'; -+------+------------+-----------+-----------+ -| NAME | RU_PER_SEC | RU_TOKENS | BURSTABLE | -+------+------------+-----------+-----------+ -| rg1 | 1000 | 100000 | NO | -+------+------------+-----------+-----------+ ++------+------------+-----------+ +| NAME | RU_PER_SEC | BURSTABLE | ++------+------------+-----------+ +| rg1 | 1000 | NO | ++------+------------+-----------+ ``` The descriptions of the columns in the `RESOURCE_GROUPS` table are as follows: * `NAME`: the name of the resource group. * `RU_PER_SEC`:the backfilling speed of the resource group. The unit is RU/second, in which RU means [Request Unit](/tidb-resource-control.md#what-is-request-unit-ru). -* `RU_TOKENS`: the number of tokens left in the resource group token bucket, and 1 token is 1 RU. * `BURSTABLE`: whether to allow the resource group to overuse the available system resources. diff --git a/mysql-compatibility.md b/mysql-compatibility.md index 49168fc2acaab..1a05c8c9173ff 100644 --- a/mysql-compatibility.md +++ b/mysql-compatibility.md @@ -260,3 +260,11 @@ TiDB does not implement certain features that have been marked as deprecated in * Specifying precision for floating point types. MySQL 8.0 [deprecates](https://dev.mysql.com/doc/refman/8.0/en/floating-point-types.html) this feature, and it is recommended to use the `DECIMAL` type instead. * The `ZEROFILL` attribute. MySQL 8.0 [deprecates](https://dev.mysql.com/doc/refman/8.0/en/numeric-type-attributes.html) this feature, and it is recommended to instead pad numeric values in your application. + +### `CREATE RESOURCE GROUP`, `DROP RESOURCE GROUP`, and `ALTER RESOURCE GROUP` statements + +The statements of creating and modifying resource groups are different from MySQL. See the following documents for details: + +- [`CREATE RESOURCE GROUP`](/sql-statements/sql-statement-create-resource-group.md) +- [`DROP RESOURCE GROUP`](/sql-statements/sql-statement-drop-resource-group.md) +- [`ALTER RESOURCE GROUP`](/sql-statements/sql-statement-alter-resource-group.md) diff --git a/sql-statements/sql-statement-alter-resource-group.md b/sql-statements/sql-statement-alter-resource-group.md index 98f448672cf19..d77a897eac6b5 100644 --- a/sql-statements/sql-statement-alter-resource-group.md +++ b/sql-statements/sql-statement-alter-resource-group.md @@ -40,7 +40,7 @@ If the `BURSTABLE` attribute is set, the corresponding resource group allows the > **Note:** > -> The `ALTER RESOURCE GROUP` statement can only be executed when the global variable [`tidb_enable_resource_group`](/system-variables.md#tidb_enable_resource_control-new-in-v660) is set to `ON`. +> The `ALTER RESOURCE GROUP` statement can only be executed when the global variable [`tidb_enable_resource_control`](/system-variables.md#tidb_enable_resource_control-new-in-v660) is set to `ON`. ## Examples @@ -54,21 +54,21 @@ mysql> CREATE RESOURCE GROUP IF NOT EXISTS rg1 -> BURSTABLE; Query OK, 0 rows affected (0.08 sec) mysql> SELECT * FROM information_schema.resource_groups WHERE NAME ='rg1'; -+------+-------------+-----------+-----------+ -| NAME | RU_PER_SEC | RU_TOKENS | BURSTABLE | -+------+-------------+-----------+-----------+ -| rg1 | 100 | 165135 | YES | -+------+-------------+-----------+-----------+ ++------+-------------+-----------+ +| NAME | RU_PER_SEC | BURSTABLE | ++------+-------------+-----------+ +| rg1 | 100 | YES | ++------+-------------+-----------+ 1 rows in set (1.30 sec) mysql> ALTER RESOURCE GROUP rg1 -> RU_PER_SEC = 200; Query OK, 0 rows affected (0.08 sec) mysql> SELECT * FROM information_schema.resource_groups WHERE NAME ='rg1'; -+------+-------------+-----------+-----------+ -| NAME | RU_PER_SEC | RU_TOKENS | BURSTABLE | -+------+-------------+-----------+-----------+ -| rg1 | 200 | 257158 | NO | -+------+-------------+-----------+-----------+ ++------+-------------+-----------+ +| NAME | RU_PER_SEC | BURSTABLE | ++------+-------------+-----------+ +| rg1 | 200 | NO | ++------+-------------+-----------+ 1 rows in set (1.30 sec) ``` diff --git a/sql-statements/sql-statement-create-resource-group.md b/sql-statements/sql-statement-create-resource-group.md index 1a22181d22d88..4c985404319e0 100644 --- a/sql-statements/sql-statement-create-resource-group.md +++ b/sql-statements/sql-statement-create-resource-group.md @@ -42,7 +42,7 @@ If the `BURSTABLE` attribute is set, the corresponding resource group allows the > **Note:** > -> The `CREATE RESOURCE GROUP` statement can only be executed when the global variable [`tidb_enable_resource_group`](/system-variables.md#tidb_enable_resource_control-new-in-v660) is set to `ON`. +> The `CREATE RESOURCE GROUP` statement can only be executed when the global variable [`tidb_enable_resource_control`](/system-variables.md#tidb_enable_resource_control-new-in-v660) is set to `ON`. ## Examples @@ -59,12 +59,12 @@ mysql> CREATE RESOURCE GROUP IF NOT EXISTS rg2 -> RU_PER_SEC = 200; Query OK, 0 rows affected (0.08 sec) mysql> SELECT * FROM information_schema.resource_groups WHERE NAME ='rg1' or NAME = 'rg2'; -+------+-------------+-----------+-----------+ -| NAME | RU_PER_SEC | RU_TOKENS | BURSTABLE | -+------+-------------+-----------+-----------+ -| rg1 | 100 | 165135 | YES | -| rg2 | 200 | 157158 | NO | -+------+-------------+-----------+-----------+ ++------+-------------+-----------+ +| NAME | RU_PER_SEC | BURSTABLE | ++------+-------------+-----------+ +| rg1 | 100 | YES | +| rg2 | 200 | NO | ++------+-------------+-----------+ 2 rows in set (1.30 sec) ``` diff --git a/sql-statements/sql-statement-drop-resource-group.md b/sql-statements/sql-statement-drop-resource-group.md index 605d0c0accf1c..1ca96cf098efe 100644 --- a/sql-statements/sql-statement-drop-resource-group.md +++ b/sql-statements/sql-statement-drop-resource-group.md @@ -22,7 +22,7 @@ ResourceGroupName: > **Note:** > -> The `DROP RESOURCE GROUP` statement can only be executed when the global variable [`tidb_enable_resource_group`](/system-variables.md#tidb_enable_resource_control-new-in-v660) is set to `ON`. +> The `DROP RESOURCE GROUP` statement can only be executed when the global variable [`tidb_enable_resource_control`](/system-variables.md#tidb_enable_resource_control-new-in-v660) is set to `ON`. ## Examples @@ -34,11 +34,11 @@ Query OK, 0 rows affected (0.22 sec) mysql> CREATE RESOURCE GROUP IF NOT EXISTS rg1 RU_PER_SEC = 500 BURSTABLE; Query OK, 0 rows affected (0.08 sec) mysql> SELECT * FROM information_schema.resource_groups WHERE NAME ='rg1'; -+------+------------+-----------+-----------+ -| NAME | RU_PER_SEC | RU_TOKENS | BURSTABLE | -+------+------------+-----------+-----------+ -| rg1 | 500 | 0 | YES | -+------+------------+-----------+-----------+ ++------+------------+-----------+ +| NAME | RU_PER_SEC | BURSTABLE | ++------+------------+-----------+ +| rg1 | 500 | YES | ++------+------------+-----------+ 1 row in set (0.01 sec) mysql> DROP RESOURCE GROUP IF EXISTS rg1 ; diff --git a/tidb-resource-control.md b/tidb-resource-control.md index a2dd15a0fbeeb..b85c7669be0c8 100644 --- a/tidb-resource-control.md +++ b/tidb-resource-control.md @@ -28,12 +28,12 @@ The introduction of the resource control feature is a milestone for TiDB. It can ## Scenarios for resource control - With this feature, you can: +With this feature, you can: - - Combine multiple small and medium-sized applications from different systems into a single TiDB cluster. When the workload of an application grows larger, it does not affect the normal operation of other applications. When the system workload is low, busy applications can still be allocated the required system resources even if they exceed the set read and write quotas, so as to achieve the maximum utilization of resources. - - Choose to combine all test environments into a single TiDB cluster, or group the batch tasks that consume more resources into a single resource group. It can improve hardware utilization and reduce operating costs while ensuring that critical applications can always get the necessary resources. +- Combine multiple small and medium-sized applications from different systems into a single TiDB cluster. When the workload of an application grows larger, it does not affect the normal operation of other applications. When the system workload is low, busy applications can still be allocated the required system resources even if they exceed the set read and write quotas, so as to achieve the maximum utilization of resources. +- Choose to combine all test environments into a single TiDB cluster, or group the batch tasks that consume more resources into a single resource group. It can improve hardware utilization and reduce operating costs while ensuring that critical applications can always get the necessary resources. - In addition, the rational use of the resource control feature can reduce the number of clusters, ease the difficulty of operation and maintenance, and save management costs. +In addition, the rational use of the resource control feature can reduce the number of clusters, ease the difficulty of operation and maintenance, and save management costs. In addition, the rational use of the resource control feature can reduce the number of clusters, ease the difficulty of operation and maintenance, and save management costs. @@ -45,7 +45,7 @@ The following table shows the consumption of TiKV storage layer CPU and IO resou | Resource | RU Weight | |:----------------|:-----------------| -| CPU | 1 RU/millisecond | +| CPU | (1/3) RU/millisecond | | Read IO | (1/64) RU/KB | | Write IO | 1 RU/KB | | Basic overhead of a read request | 0.25 RU | @@ -53,7 +53,7 @@ The following table shows the consumption of TiKV storage layer CPU and IO resou Based on the above table, assuming that the TiKV time consumed by a resource group is `c` milliseconds, `r1` requests that read `r2` KB data, and `w1` write requests that write `w2` KB data, then the formula for the total RUs consumed by the resource group is as follows: -`c` + (`r1` \* 0.25 + `r2`/64) + (1.5 * `w1` + `w2`) +`c`/3 + (`r1` \* 0.25 + `r2`/64) + (1.5 * `w1` + `w2`) ## Parameters for resource control @@ -156,7 +156,7 @@ TiDB regularly collects runtime information about resource control and provides ## Tool Compatibility -The resource control feature is not compatible with data export/import and replication tools including BR, TiDB Lightning, and TiCDC. +The resource control feature is not compatible with data export/import and replication tools including BR, TiDB Lightning, and TiCDC. These tools simply ignore the metadata information of the resource groups in the cluster. ## Limitations From b1db47c92e12c38d3c144b628123c816c585d527 Mon Sep 17 00:00:00 2001 From: xixirangrang Date: Wed, 8 Feb 2023 21:37:05 +0800 Subject: [PATCH 33/63] Apply suggestions from code review --- .../sql-statement-show-create-resource-group.md | 13 +++++++++---- system-variables.md | 2 +- tidb-resource-control.md | 6 +++--- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/sql-statements/sql-statement-show-create-resource-group.md b/sql-statements/sql-statement-show-create-resource-group.md index e3a8ae72071c3..9b3cc33927338 100644 --- a/sql-statements/sql-statement-show-create-resource-group.md +++ b/sql-statements/sql-statement-show-create-resource-group.md @@ -19,19 +19,24 @@ ResourceGroupName ::= ## Examples -View the current definition of the resource group `rg1`. +Create a resource group `rg1`. ```sql CREATE RESOURCE GROUP rg1 RU_PER_SEC=100; Query OK, 0 rows affected (0.10 sec) ``` +View the definition of `rg1`. + ```sql SHOW CREATE RESOURCE GROUP rg1; ***************************[ 1. row ]*************************** -Resource_Group | rg1 -Create Resource Group | CREATE RESOURCE GROUP `rg1` RU_PER_SEC=100 -1 row in set (0.00 sec) ++----------------+--------------------------------------------+ +| Resource_Group | Create Resource Group | ++----------------+--------------------------------------------+ +| rg1 | CREATE RESOURCE GROUP `rg1` RU_PER_SEC=100 | ++----------------+--------------------------------------------+ +1 row in set (0.01 sec) ``` ## MySQL compatibility diff --git a/system-variables.md b/system-variables.md index b6da45409bd1b..3e67ca17aa0b2 100644 --- a/system-variables.md +++ b/system-variables.md @@ -1809,7 +1809,7 @@ MPP is a distributed computing framework provided by the TiFlash engine, which a - Persists to cluster: Yes - Default value: `OFF` - Type: Boolean -- This variable is a switch for [the resource control feature](/tidb-resource-control.md). When this variable is set to `ON`, the TiDB cluster supports resource isolation of applications based on resource groups. +- This variable is a switch for [the resource control feature](/tidb-resource-control.md). When this variable is set to `ON`, the TiDB cluster can isolate application resources based on resource groups. ### tidb_enable_reuse_chunk New in v6.4.0 diff --git a/tidb-resource-control.md b/tidb-resource-control.md index b85c7669be0c8..5dc9a8551a9e9 100644 --- a/tidb-resource-control.md +++ b/tidb-resource-control.md @@ -9,11 +9,11 @@ summary: Learn how to use the resource control feature to control and schedule a > > This feature is experimental and its form and usage may change in subsequent versions. -Using the resource control feature, as a cluster administrator, you can define resource groups and limit the read and write quotas of resource groups. After you bind users to a resource group, the TiDB layer will perform flow control on the user's read and write requests according to the read and write quotas set by the bound resource group. Meanwhile, the TiKV layer will schedule the requests according to the priority of the read and write quota mapping. Through flow control and scheduling, you can achieve resource isolation of your applications and meet the quality of service (QoS) requirements. +As a cluster administrator, you can use the resource control feature to set read and write quotas for resource groups, and bind users to those groups. This allows the TiDB layer to control the flow of user read and write requests based on the quotas set for the resource group, while the TiKV layer schedules the requests based on the priority of the read and write quota mapping. By doing this, you can ensure resource isolation for your applications and meet quality of service (QoS) requirements. The TiDB resource control feature provides two layers of resource management capabilities: the flow control capability at the TiDB layer and the priority scheduling capability at the TiKV layer. The two capabilities are orthogonal and can be enabled separately or simultaneously. See the [Parameters for resource control](#parameters-for-resource-control) for details. -- TiDB flow control: TiDB flow control uses the token bucket algorithm (`RU_TOKENS`). The number of tokens consumed by read and write requests cannot exceed the number of tokens accumulated in the corresponding resource group bucket. If there are not enough tokens in the bucket, and the resource group does not specify the `BURSTABLE` option, the requests to the resource group will wait for the token bucket to backfill the tokens and retry. The retry may fail due to timeout. +- TiDB flow control: TiDB flow control uses the [token bucket algorithm](https://en.wikipedia.org/wiki/Token_bucket). If there are not enough tokens in the bucket, and the resource group does not specify the `BURSTABLE` option, the requests to the resource group will wait for the token bucket to backfill the tokens and retry. The retry might fail due to timeout. - TiKV scheduling: If [`resource-control.enabled`](/tikv-configuration-file.md#resource-control) is enabled, TiKV uses the value of `RU_PER_SEC` of each resource group to map the read and write requests of each resource group to their own priorities. Based on their own priorities, the storage layer uses the priority queue to schedule and process requests. The introduction of the resource control feature is a milestone for TiDB. It can divide a distributed database cluster into multiple logical units. Even if an individual unit overuses resources, it does not crowd out the resources needed by other units. @@ -156,7 +156,7 @@ TiDB regularly collects runtime information about resource control and provides ## Tool Compatibility -The resource control feature is not compatible with data export/import and replication tools including BR, TiDB Lightning, and TiCDC. These tools simply ignore the metadata information of the resource groups in the cluster. +The resource control feature is still in its experimental stage and does not impact the regular usage of data import, export, and other replication tools. BR, TiDB Lightning, and TiCDC do not currently support resource control related DDL processing, and their resource consumption is not limited by resource control. ## Limitations From bd7ce25d71ca24f83b08bca088170a741fe7e7ba Mon Sep 17 00:00:00 2001 From: xixirangrang Date: Thu, 9 Feb 2023 17:21:02 +0800 Subject: [PATCH 34/63] Apply suggestions from code review --- tidb-resource-control.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tidb-resource-control.md b/tidb-resource-control.md index 5dc9a8551a9e9..41378d7e8abcd 100644 --- a/tidb-resource-control.md +++ b/tidb-resource-control.md @@ -53,7 +53,7 @@ The following table shows the consumption of TiKV storage layer CPU and IO resou Based on the above table, assuming that the TiKV time consumed by a resource group is `c` milliseconds, `r1` requests that read `r2` KB data, and `w1` write requests that write `w2` KB data, then the formula for the total RUs consumed by the resource group is as follows: -`c`/3 + (`r1` \* 0.25 + `r2`/64) + (1.5 * `w1` + `w2`) +`c`\* 1/3 + (`r1` \* 0.25 + `r2` \* 1/64) + (1.5 \* `w1` + `w2` \* 1 \* `n`) ## Parameters for resource control @@ -75,7 +75,7 @@ The results of the combinations of these two parameters are shown in the followi | `resource-control.enabled` | `tidb_enable_resource_control`= ON | `tidb_enable_resource_control`= OFF | |:----------------------------|:-------------------------------------|:-------------------------------------| | `resource-control.enabled`= true | Flow control and scheduling (recommended) | Invalid combination | -| `resource-control.enabled`= false | Only flow control | The feature is disabled. | +| `resource-control.enabled`= false | Only flow control (not recommended) | The feature is disabled. | ## How to use resource control From 5a1207c4476286976787371e30bbcdde1c274dcd Mon Sep 17 00:00:00 2001 From: xixirangrang Date: Thu, 9 Feb 2023 17:24:26 +0800 Subject: [PATCH 35/63] Update tidb-resource-control.md --- tidb-resource-control.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tidb-resource-control.md b/tidb-resource-control.md index 41378d7e8abcd..0db34ac7b59ac 100644 --- a/tidb-resource-control.md +++ b/tidb-resource-control.md @@ -51,7 +51,7 @@ The following table shows the consumption of TiKV storage layer CPU and IO resou | Basic overhead of a read request | 0.25 RU | | Basic overhead of a write request | 1.5 RU | -Based on the above table, assuming that the TiKV time consumed by a resource group is `c` milliseconds, `r1` requests that read `r2` KB data, and `w1` write requests that write `w2` KB data, then the formula for the total RUs consumed by the resource group is as follows: +Based on the above table, assuming that the TiKV time consumed by a resource group is `c` milliseconds, `r1` requests that read `r2` KB data, `w1` write requests that write `w2` KB data, and the number of non-witness TiKV nodes in the cluster is `n` , then the formula for the total RUs consumed by the resource group is as follows: `c`\* 1/3 + (`r1` \* 0.25 + `r2` \* 1/64) + (1.5 \* `w1` + `w2` \* 1 \* `n`) From a46e7a0e18ad64bc82e84b93e88669ca70b70e07 Mon Sep 17 00:00:00 2001 From: xixirangrang Date: Thu, 9 Feb 2023 17:25:00 +0800 Subject: [PATCH 36/63] Update tidb-resource-control.md --- tidb-resource-control.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tidb-resource-control.md b/tidb-resource-control.md index 0db34ac7b59ac..f5fc29ddb3e56 100644 --- a/tidb-resource-control.md +++ b/tidb-resource-control.md @@ -51,7 +51,7 @@ The following table shows the consumption of TiKV storage layer CPU and IO resou | Basic overhead of a read request | 0.25 RU | | Basic overhead of a write request | 1.5 RU | -Based on the above table, assuming that the TiKV time consumed by a resource group is `c` milliseconds, `r1` requests that read `r2` KB data, `w1` write requests that write `w2` KB data, and the number of non-witness TiKV nodes in the cluster is `n` , then the formula for the total RUs consumed by the resource group is as follows: +Based on the above table, assuming that the TiKV time consumed by a resource group is `c` milliseconds, `r1` requests that read `r2` KB data, `w1` write requests that write `w2` KB data, and the number of non-witness TiKV nodes in the cluster is `n`, then the formula for the total RUs consumed by the resource group is as follows: `c`\* 1/3 + (`r1` \* 0.25 + `r2` \* 1/64) + (1.5 \* `w1` + `w2` \* 1 \* `n`) From 757aa33fc9d02bab8ecc26f16b93a23cec58d532 Mon Sep 17 00:00:00 2001 From: xixirangrang Date: Thu, 9 Feb 2023 21:06:02 +0800 Subject: [PATCH 37/63] Update tidb-resource-control.md --- tidb-resource-control.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/tidb-resource-control.md b/tidb-resource-control.md index f5fc29ddb3e56..eb6fcae93c0d4 100644 --- a/tidb-resource-control.md +++ b/tidb-resource-control.md @@ -35,8 +35,6 @@ With this feature, you can: In addition, the rational use of the resource control feature can reduce the number of clusters, ease the difficulty of operation and maintenance, and save management costs. -In addition, the rational use of the resource control feature can reduce the number of clusters, ease the difficulty of operation and maintenance, and save management costs. - ## What is Request Unit (RU) Request Unit (RU) is TiDB's unified abstraction unit for system resources, which currently includes CPU, IOPS and IO bandwidth metrics. The consumption of these three metrics is represented by RU according to a certain ratio. From 76494af506c5ae235266433121fba00e4b4a4418 Mon Sep 17 00:00:00 2001 From: xixirangrang Date: Sat, 11 Feb 2023 22:36:16 +0800 Subject: [PATCH 38/63] Apply suggestions from code review Co-authored-by: Grace Cai Co-authored-by: glorv --- grafana-resource-control-dashboard.md | 36 +++++++------- .../information-schema-resource-groups.md | 8 ++-- mysql-compatibility.md | 2 +- .../sql-statement-alter-resource-group.md | 30 ++++++------ .../sql-statement-create-resource-group.md | 10 ++-- sql-statements/sql-statement-create-user.md | 10 ++-- system-variables.md | 2 +- tidb-resource-control.md | 48 ++++++++++--------- tikv-configuration-file.md | 6 +-- 9 files changed, 77 insertions(+), 75 deletions(-) diff --git a/grafana-resource-control-dashboard.md b/grafana-resource-control-dashboard.md index 9b36744751250..1413e64cf71b4 100644 --- a/grafana-resource-control-dashboard.md +++ b/grafana-resource-control-dashboard.md @@ -7,30 +7,30 @@ summary: Learn some key metrics displayed on the Grafana Resource Control dashbo If you use TiUP to deploy the TiDB cluster, the monitoring system (Prometheus & Grafana) is deployed at the same time. For more information, see [Overview of the Monitoring Framework](/tidb-monitoring-framework.md). -The Grafana dashboard is divided into a series of sub dashboards which include Overview, PD, TiDB, TiKV, Node\_exporter, Disk Performance, and Performance\_overview. A lot of metrics are there to help you diagnose. +The Grafana dashboard is divided into a series of sub dashboards which include Overview, PD, TiDB, TiKV, Node\_exporter, Disk Performance, and Performance\_overview. -You can get an overview of the resource control status from the PD dashboard, where the key metrics are displayed. This document provides a detailed description of these key metrics. +If your cluster has used the [Resource Control](tidb-resource-control.md) feature, you can get an overview of the resource consumption status from the Resource Control dashboard. -This document describes some key monitoring metrics displayed on the Resource Control Dashboard. +This document describes some key monitoring metrics displayed on the Resource Control dashboard. ## Metrics about Request Unit -- RU: the [Request Unit (RU)](/tidb-resource-control.md#what-is-request-unit-ru) consumption information of each resource group is calculated in real time. `total` is the sum of the Request Units consumed by all Resource Groups. The Request Unit consumption of each resource group should be equal to the sum of its read consumption (Read Request Unit) and write consumption (Write Request Unit). -- RU Per Query: the average number of Request Units consumed by each SQL statement per second. It is obtained by dividing the above Request Unit by the number of SQL statements executed per second. -- RRU: the Read Request Unit consumption information of each resource group is calculated in real time. `total` is the sum of the Read Request Units consumed by all Resource Groups. -- RRU Per Query: the average number of Read Request Units consumed by each SQL statement per second. It is obtained by dividing the above Read Request Unit by the number of SQL statements executed per second. -- WRU: the Write Request Unit consumption information of each resource group is calculated in real time. `total` is the sum of the Write Request Units consumed by all Resource Groups. -- WRU Per Query: the average number of Write Request Units consumed by each SQL statement per second. It is obtained by dividing the above Write Request Unit by the number of SQL statements executed per second. +- RU: the [Request Unit (RU)](/tidb-resource-control.md#what-is-request-unit-ru) consumption information of each resource group, calculated in real time. `total` is the sum of the Request Units consumed by all Resource Groups. The Request Unit consumption of each resource group should be equal to the sum of its read consumption (Read Request Unit) and write consumption (Write Request Unit). +- RU Per Query: the average number of Request Units consumed by each SQL statement per second. It is obtained by dividing the above RU metric by the number of SQL statements executed per second. +- RRU: the Read Request Unit consumption information of each resource group, calculated in real time. `total` is the sum of the Read Request Units consumed by all Resource Groups. +- RRU Per Query: the average number of Read Request Units consumed by each SQL statement per second. It is obtained by dividing the above RRU metric by the number of SQL statements executed per second. +- WRU: the Write Request Unit consumption information of each resource group, calculated in real time. `total` is the sum of the Write Request Units consumed by all Resource Groups. +- WRU Per Query: the average number of Write Request Units consumed by each SQL statement per second. It is obtained by dividing the above WRU metric by the number of SQL statements executed per second. ## Metrics about resources - KV Request Count: the number of KV requests is calculated in real time for each resource group. They are divided into read and write types. `total` is the sum of the KV requests involved by all Resource Groups. -- KV Request Count Per Query: the average number of read and write KV requests by each SQL statement per second. It is obtained by dividing the above KV Request Count by the number of SQL statements executed per second. -- Bytes Read: the amount of data read is calculated in real time for each resource group. `total` is the sum of the data read by all Resource Groups. -- Bytes Read Per Query: the average amount of data read by each SQL statement per second. It is obtained by dividing the above Bytes Read by the number of SQL statements executed per second. -- Bytes Written: the amount of data written is calculated in real time for each resource group. `total` is the sum of the data written by all Resource Groups. -- Bytes Written Per Query: the average amount of data written by each SQL statement per second. It is obtained by dividing the above Bytes Written by the number of SQL statements executed per second. -- KV CPU Time: the KV layer CPU time consumed is calculated in real time for each resource group. `total` is the sum of the KV layer CPU time consumed by all Resource Groups. -- KV CPU Time Per Query: the average KV layer CPU time consumed by each SQL statement per second. It is obtained by dividing the above KV CPU Time by the number of SQL statements executed per second. -- SQL CPU Time: the SQL layer CPU time consumed is calculated in real time for each resource group. `total` is the sum of the SQL layer CPU time consumed by all Resource Groups. -- SQL CPU Time Per Query: the average SQL layer CPU time consumed by each SQL statement per second. It is obtained by dividing the above SQL CPU Time by the number of SQL statements executed per second. +- KV Request Count Per Query: the average number of read and write KV requests by each SQL statement per second. It is obtained by dividing the above KV Request Count metric by the number of SQL statements executed per second. +- Bytes Read: the amount of data read by each Resource Group, calculated per second. `total` is the sum of the data read by all Resource Groups. +- Bytes Read Per Query: the average amount of data read by each SQL statement per second. It is obtained by dividing the above Bytes Read metric by the number of SQL statements executed per second. +- Bytes Written: the amount of data written by each Resource Group, calculated in real time. `total` is the sum of the data written by all Resource Groups. +- Bytes Written Per Query: the average amount of data written by each SQL statement per second. It is obtained by dividing the above Bytes Written metric by the number of SQL statements executed per second. +- KV CPU Time: the KV layer CPU time consumed by each Resource Group, calculated in real time . `total` is the sum of the KV layer CPU time consumed by all Resource Groups. +- KV CPU Time Per Query: the average KV layer CPU time consumed by each SQL statement per second. It is obtained by dividing the above KV CPU Time metric by the number of SQL statements executed per second. +- SQL CPU Time: the SQL layer CPU time consumed by each Resource Group, calculated in real time. `total` is the sum of the SQL layer CPU time consumed by all Resource Groups. +- SQL CPU Time Per Query: the average SQL layer CPU time consumed by each SQL statement per second. It is obtained by dividing the above SQL CPU Time metric by the number of SQL statements executed per second. diff --git a/information-schema/information-schema-resource-groups.md b/information-schema/information-schema-resource-groups.md index 045f126fe8249..a2993c385a9d1 100644 --- a/information-schema/information-schema-resource-groups.md +++ b/information-schema/information-schema-resource-groups.md @@ -7,9 +7,9 @@ summary: Learn the `RESOURCE_GROUPS` information_schema table. > **Warning:** > -> This feature is experimental and its form and usage may change in subsequent versions. +> This feature is experimental and its form and usage might change in subsequent versions. -The `RESOURCE_GROUPS` table shows information about all resource groups. See [Use Resource Control to Achieve Resource Isolation](/tidb-resource-control.md). +The `RESOURCE_GROUPS` table shows the information about all resource groups. For more information, see [Use Resource Control to Achieve Resource Isolation](/tidb-resource-control.md). ```sql USE information_schema; @@ -29,12 +29,10 @@ DESC resource_groups; ## Examples -{{< copyable "sql" >}} - ```sql mysql> CREATE RESOURCE GROUP rg1 RU_PER_SEC=1000; -- Create the resource group rg1 Query OK, 0 rows affected (0.34 sec) -mysql> SHOW CREATE RESOURCE GROUP rg1; -- Displays the definition of the rg1 resource group. +mysql> SHOW CREATE RESOURCE GROUP rg1; -- Display the definition of the rg1 resource group +----------------+---------------------------------------------+ | Resource_Group | Create Resource Group | +----------------+---------------------------------------------+ diff --git a/mysql-compatibility.md b/mysql-compatibility.md index 65c29b051b04f..2fe3480278848 100644 --- a/mysql-compatibility.md +++ b/mysql-compatibility.md @@ -259,7 +259,7 @@ TiDB does not implement certain features that have been marked as deprecated in ### `CREATE RESOURCE GROUP`, `DROP RESOURCE GROUP`, and `ALTER RESOURCE GROUP` statements -The statements of creating and modifying resource groups are different from MySQL. See the following documents for details: +For the statements of creating, modifying, and dropping resource groups, the supported parameters are different from that of MySQL. See the following documents for details: - [`CREATE RESOURCE GROUP`](/sql-statements/sql-statement-create-resource-group.md) - [`DROP RESOURCE GROUP`](/sql-statements/sql-statement-drop-resource-group.md) diff --git a/sql-statements/sql-statement-alter-resource-group.md b/sql-statements/sql-statement-alter-resource-group.md index d77a897eac6b5..56df867d26a66 100644 --- a/sql-statements/sql-statement-alter-resource-group.md +++ b/sql-statements/sql-statement-alter-resource-group.md @@ -5,7 +5,7 @@ summary: Learn the usage of ALTER RESOURCE GROUP in TiDB. # ALTER RESOURCE GROUP -The `ALTER RESOURCE GROUP` statement is used to modify the resource group in a database. +The `ALTER RESOURCE GROUP` statement is used to modify a resource group in a database. ## Synopsis @@ -30,13 +30,13 @@ DirectResourceGroupOption: ``` -TiDB supports the following `DirectResourceGroupOption`, where [Request Unit (RU)](/tidb-resource-control.md#what-is-request-unit-ru) is TiDB's unified abstraction unit for CPU, IO, and other system resources. +TiDB supports the following `DirectResourceGroupOption`, where [Request Unit (RU)](/tidb-resource-control.md#what-is-request-unit-ru) is a unified abstraction unit in TiDB for CPU, IO, and other system resources. | Option | Description | Example | |---------------|-------------------------------------|------------------------| -|`RU_PER_SEC` | Rate of RU filling per second |`RU_PER_SEC = 500` indicates that this resource group is backfilled with 500 RUs per second | +| `RU_PER_SEC` | Rate of RU backfilling per second | `RU_PER_SEC = 500` indicates that this resource group is backfilled with 500 RUs per second | -If the `BURSTABLE` attribute is set, the corresponding resource group allows the available system resources to be used exceeding the quota. +If the `BURSTABLE` attribute is set, TiDB allows the corresponding resource group to use the available system resources when the quota is exceeded. > **Note:** > @@ -54,27 +54,27 @@ mysql> CREATE RESOURCE GROUP IF NOT EXISTS rg1 -> BURSTABLE; Query OK, 0 rows affected (0.08 sec) mysql> SELECT * FROM information_schema.resource_groups WHERE NAME ='rg1'; -+------+-------------+-----------+ -| NAME | RU_PER_SEC | BURSTABLE | -+------+-------------+-----------+ -| rg1 | 100 | YES | -+------+-------------+-----------+ ++------+------------+-----------+ +| NAME | RU_PER_SEC | BURSTABLE | ++------+------------+-----------+ +| rg1 | 100 | YES | ++------+------------+-----------+ 1 rows in set (1.30 sec) mysql> ALTER RESOURCE GROUP rg1 -> RU_PER_SEC = 200; Query OK, 0 rows affected (0.08 sec) mysql> SELECT * FROM information_schema.resource_groups WHERE NAME ='rg1'; -+------+-------------+-----------+ -| NAME | RU_PER_SEC | BURSTABLE | -+------+-------------+-----------+ -| rg1 | 200 | NO | -+------+-------------+-----------+ ++------+------------+-----------+ +| NAME | RU_PER_SEC | BURSTABLE | ++------+------------+-----------+ +| rg1 | 200 | NO | ++------+------------+-----------+ 1 rows in set (1.30 sec) ``` ## MySQL compatibility -MySQL also supports [ALTER RESOURCE GROUP](https://dev.mysql.com/doc/refman/8.0/en/alter-resource-group.html). However, the accepted parameters are different from TiDB so that they are not compatible. +MySQL also supports [ALTER RESOURCE GROUP](https://dev.mysql.com/doc/refman/8.0/en/alter-resource-group.html). However, the acceptable parameters are different from that of TiDB so that they are not compatible. ## See also diff --git a/sql-statements/sql-statement-create-resource-group.md b/sql-statements/sql-statement-create-resource-group.md index 4c985404319e0..c721ff2fd5009 100644 --- a/sql-statements/sql-statement-create-resource-group.md +++ b/sql-statements/sql-statement-create-resource-group.md @@ -30,15 +30,15 @@ DirectResourceGroupOption: ``` -The resource group name parameter (`ResourceGroupName`) is globally unique and cannot be duplicated. +The resource group name parameter (`ResourceGroupName`) must be globally unique. -TiDB supports the following `DirectResourceGroupOption`, where [Request Unit (RU)](/tidb-resource-control.md#what-is-request-unit-ru) is TiDB's unified abstraction unit for CPU, IO, and other system resources. +TiDB supports the following `DirectResourceGroupOption`, where [Request Unit (RU)](/tidb-resource-control.md#what-is-request-unit-ru) is a unified abstraction unit in TiDB for CPU, IO, and other system resources. | Option | Description | Example | |---------------|-------------------------------------|------------------------| -|`RU_PER_SEC` | Rate of RU filling per second |`RU_PER_SEC = 500` indicates that this resource group is backfilled with 500 RUs per second | +| `RU_PER_SEC` | Rate of RU backfilling per second | `RU_PER_SEC = 500` indicates that this resource group is backfilled with 500 RUs per second | -If the `BURSTABLE` attribute is set, the corresponding resource group allows the system resources to be used exceeding the quota. +If the `BURSTABLE` attribute is set, TiDB allows the corresponding resource group to use the available system resources when the quota is exceeded. > **Note:** > @@ -70,7 +70,7 @@ mysql> SELECT * FROM information_schema.resource_groups WHERE NAME ='rg1' or NAM ## MySQL compatibility -MySQL also supports [CREATE RESOURCE GROUP](https://dev.mysql.com/doc/refman/8.0/en/create-resource-group.html). However, the accepted parameters are different from TiDB so that they are not compatible. +MySQL also supports [CREATE RESOURCE GROUP](https://dev.mysql.com/doc/refman/8.0/en/create-resource-group.html). However, the acceptable parameters are different from that of TiDB so that they are not compatible. ## See also diff --git a/sql-statements/sql-statement-create-user.md b/sql-statements/sql-statement-create-user.md index 2b373e844a1af..db460762dbaea 100644 --- a/sql-statements/sql-statement-create-user.md +++ b/sql-statements/sql-statement-create-user.md @@ -139,11 +139,11 @@ SELECT USER, HOST, USER_ATTRIBUTES FROM MYSQL.USER WHERE USER='newuser7'; ``` ```sql -+-----------+------+---------------------------------------------------+ -| USER | HOST | ATTRIBUTE | -+-----------+------+---------------------------------------------------+ -| newuser7 | % | {"resource_group": "rg1"} | -+-----------+------+---------------------------------------------------+ ++----------+------+---------------------------+ +| USER | HOST | USER_ATTRIBUTES | ++----------+------+---------------------------+ +| newuser7 | % | {"resource_group": "rg1"} | ++----------+------+---------------------------+ 1 rows in set (0.00 sec) ``` diff --git a/system-variables.md b/system-variables.md index a78821a1827d6..68da416941a0b 100644 --- a/system-variables.md +++ b/system-variables.md @@ -1810,7 +1810,7 @@ MPP is a distributed computing framework provided by the TiFlash engine, which a > **Warning:** > -> This feature is experimental and its form and usage may change in subsequent versions. +> This feature is experimental and its form and usage might change in subsequent versions. - Scope: GLOBAL - Persists to cluster: Yes diff --git a/tidb-resource-control.md b/tidb-resource-control.md index eb6fcae93c0d4..dc709a535f14e 100644 --- a/tidb-resource-control.md +++ b/tidb-resource-control.md @@ -7,14 +7,14 @@ summary: Learn how to use the resource control feature to control and schedule a > **Warning:** > -> This feature is experimental and its form and usage may change in subsequent versions. +> This feature is experimental and its form and usage might change in subsequent versions. -As a cluster administrator, you can use the resource control feature to set read and write quotas for resource groups, and bind users to those groups. This allows the TiDB layer to control the flow of user read and write requests based on the quotas set for the resource group, while the TiKV layer schedules the requests based on the priority of the read and write quota mapping. By doing this, you can ensure resource isolation for your applications and meet quality of service (QoS) requirements. +As a cluster administrator, you can use the resource control feature to create resource groups, set read and write quotas for resource groups, and bind users to those groups. This allows the TiDB layer to control the flow of user read and write requests based on the quotas set for the resource groups, and allows the TiKV layer to schedule the requests based on the priority mapped to the read and write quota. By doing this, you can ensure resource isolation for your applications and meet quality of service (QoS) requirements. -The TiDB resource control feature provides two layers of resource management capabilities: the flow control capability at the TiDB layer and the priority scheduling capability at the TiKV layer. The two capabilities are orthogonal and can be enabled separately or simultaneously. See the [Parameters for resource control](#parameters-for-resource-control) for details. +The TiDB resource control feature provides two layers of resource management capabilities: the flow control capability at the TiDB layer and the priority scheduling capability at the TiKV layer. The two capabilities can be enabled separately or simultaneously. See the [Parameters for resource control](#parameters-for-resource-control) for details. -- TiDB flow control: TiDB flow control uses the [token bucket algorithm](https://en.wikipedia.org/wiki/Token_bucket). If there are not enough tokens in the bucket, and the resource group does not specify the `BURSTABLE` option, the requests to the resource group will wait for the token bucket to backfill the tokens and retry. The retry might fail due to timeout. -- TiKV scheduling: If [`resource-control.enabled`](/tikv-configuration-file.md#resource-control) is enabled, TiKV uses the value of `RU_PER_SEC` of each resource group to map the read and write requests of each resource group to their own priorities. Based on their own priorities, the storage layer uses the priority queue to schedule and process requests. +- TiDB flow control: TiDB flow control uses the [token bucket algorithm](https://en.wikipedia.org/wiki/Token_bucket). If there are not enough tokens in a bucket, and the resource group does not specify the `BURSTABLE` option, the requests to the resource group will wait for the token bucket to backfill the tokens and retry. The retry might fail due to timeout. +- TiKV scheduling: if [`resource-control.enabled`](/tikv-configuration-file.md#resource-control) is enabled, TiKV uses the value of `RU_PER_SEC` of each resource group to determine the priority of the read and write requests for each resource group. Based on the priorities, the storage layer uses the priority queue to schedule and process requests. The introduction of the resource control feature is a milestone for TiDB. It can divide a distributed database cluster into multiple logical units. Even if an individual unit overuses resources, it does not crowd out the resources needed by other units. @@ -28,6 +28,8 @@ The introduction of the resource control feature is a milestone for TiDB. It can ## Scenarios for resource control +The introduction of the resource control feature is a milestone for TiDB. It can divide a distributed database cluster into multiple logical units. Even if an individual unit overuses resources, it does not crowd out the resources needed by other units. + With this feature, you can: - Combine multiple small and medium-sized applications from different systems into a single TiDB cluster. When the workload of an application grows larger, it does not affect the normal operation of other applications. When the system workload is low, busy applications can still be allocated the required system resources even if they exceed the set read and write quotas, so as to achieve the maximum utilization of resources. @@ -37,19 +39,19 @@ In addition, the rational use of the resource control feature can reduce the num ## What is Request Unit (RU) -Request Unit (RU) is TiDB's unified abstraction unit for system resources, which currently includes CPU, IOPS and IO bandwidth metrics. The consumption of these three metrics is represented by RU according to a certain ratio. +Request Unit (RU) is a unified abstraction unit in TiDB for system resources, which currently includes CPU, IOPS, and IO bandwidth metrics. The consumption of these three metrics is represented by RU according to a certain ratio. The following table shows the consumption of TiKV storage layer CPU and IO resources by user requests and the corresponding RU weights. | Resource | RU Weight | |:----------------|:-----------------| -| CPU | (1/3) RU/millisecond | -| Read IO | (1/64) RU/KB | +| CPU | 1/3 RU per millisecond | +| Read IO | 1/64 RU per KB | | Write IO | 1 RU/KB | | Basic overhead of a read request | 0.25 RU | | Basic overhead of a write request | 1.5 RU | -Based on the above table, assuming that the TiKV time consumed by a resource group is `c` milliseconds, `r1` requests that read `r2` KB data, `w1` write requests that write `w2` KB data, and the number of non-witness TiKV nodes in the cluster is `n`, then the formula for the total RUs consumed by the resource group is as follows: +Based on the above table, assuming that the TiKV time consumed by a resource group is `c` milliseconds, `r1` times of requests read `r2` KB data, `w1` times of write requests write `w2` KB data, and the number of non-witness TiKV nodes in the cluster is `n`. Then, the formula for the total RUs consumed by the resource group is as follows: `c`\* 1/3 + (`r1` \* 0.25 + `r2` \* 1/64) + (1.5 \* `w1` + `w2` \* 1 \* `n`) @@ -57,14 +59,14 @@ Based on the above table, assuming that the TiKV time consumed by a resource gro The resource control feature introduces two new global variables. -* TiDB: you can use the system variable [`tidb_enable_resource_control`](/system-variables.md#tidb-tidb_enable_resource_control-new-in-v660) to control whether to enable flow control for a resource group. -* TiKV: you can use the parameter [`resource-control.enabled`](/tikv-configuration-file.md#resource-control) to control whether to use request scheduling based on resource group quotas. +* TiDB: you can use the [`tidb_enable_resource_control`](/system-variables.md#tidb-tidb_enable_resource_control-new-in-v660) system variable to control whether to enable flow control for resource groups. +* TiKV: you can use the [`resource-control.enabled`](/tikv-configuration-file.md#resource-control) parameter to control whether to use request scheduling based on resource group quotas. > **Note:** > -> The parameter `resource-control.enabled` is disabled by default. It does not support dynamic modification. You need to contact the [PingCAP support team](/tidb-cloud/tidb-cloud-support.md) to enable it for TiDB Cloud Dedicated Tier clusters. +> In TiDB Cloud, the value of the `resource-control.enabled` parameter is `false` by default and does not support dynamic modification. If you need to enable it for TiDB Cloud Dedicated Tier clusters, contact [TiDB Cloud Support](/tidb-cloud/tidb-cloud-support.md). @@ -79,7 +81,7 @@ The results of the combinations of these two parameters are shown in the followi To create, modify, or delete a resource group, you need to have the `SUPER` or `RESOURCE_GROUP_ADMIN` privilege. -You can create a resource group in the cluster by using [`CREATE RESOURCE GROUP`](/sql-statements/sql-statement-create-resource-group.md), and then bind the users to a specific resource group by using [`CREATE USER`](/sql-statements/ sql-statement-create-user.md) or [`ALTER USER`](/sql-statements/sql-statement-alter-user.md). +You can create a resource group in the cluster by using [`CREATE RESOURCE GROUP`](/sql-statements/sql-statement-create-resource-group.md), and then bind users to a specific resource group by using [`CREATE USER`](/sql-statements/ sql-statement-create-user.md) or [`ALTER USER`](/sql-statements/sql-statement-alter-user.md). For an existing resource group, you can modify the read and write quota of the resource group by using [`ALTER RESOURCE GROUP`](/sql-statements/sql-statement-alter-resource-group.md). The quota changes to the resource group take effect immediately. @@ -88,7 +90,7 @@ You can delete a resource group by using [`DROP RESOURCE GROUP`](/sql-statements > **Note:** > > - When you bind a user to a resource group by using `CREATE USER` or `ALTER USER`, it will not take effect for the user's existing sessions, but only for the user's new sessions. -> - If a user is not bound to a resource group or is bound to a `default` resource group, the user's requests are not subject to TiDB's flow control restrictions. The `default` resource group is currently not visible to the user and cannot be created or modified. +> - If a user is not bound to a resource group or is bound to a `default` resource group, the user's requests are not subject to the flow control restrictions of TiDB. The `default` resource group is currently not visible to the user and cannot be created or modified. ### Step 1. Enable the resource control feature @@ -100,7 +102,7 @@ SET GLOBAL tidb_enable_resource_control = 'ON'; -In TiKV, set the parameter [`resource-control.enabled`](/tikv-configuration-file.md#resource-control) to `true`. +Set the TiKV [`resource-control.enabled`](/tikv-configuration-file.md#resource-control) parameter to `true`. @@ -120,7 +122,7 @@ The following is an example of how to create a resource group and bind users to CREATE RESOURCE GROUP IF NOT EXISTS rg1 RU_PER_SEC = 500 BURSTABLE; ``` -2. Create a resource group `rg2`. The RU backfill rate is 500 RUs per second and does not allow applications in this resource group to overrun resources. +2. Create a resource group `rg2`. The RU backfill rate is 600 RUs per second and does not allow applications in this resource group to overrun resources. ```sql CREATE RESOURCE GROUP IF NOT EXISTS rg2 RU_PER_SEC = 600; @@ -136,31 +138,33 @@ The following is an example of how to create a resource group and bind users to ALTER USER usr2 RESOURCE GROUP rg2; ``` -After you complete the above operations of creating resource groups and binding users, the resource consumption of newly created sessions will be controlled by the specified quota. If the system load is relatively high and there is no spare capacity, the resource consumption rate of `usr2` will be strictly controlled not to exceed the quota. Because `usr1` bound by `rg1` is configured with `BURSTABLE`, the consumption rate of `usr1` is allowed to exceed the quota. +After you complete the above operations of creating resource groups and binding users, the resource consumption of newly created sessions will be controlled by the specified quota. If the system workload is relatively high and there is no spare capacity, the resource consumption rate of `usr2` will be strictly controlled not to exceed the quota. Because `usr1` is bound by `rg1` with `BURSTABLE` configured, the consumption rate of `usr1` is allowed to exceed the quota. If the resource group corresponds to a request with insufficient quota, the client's request will wait. If the wait time is too long, the request will report an error. -## Monitoring and charts +## Monitoring metrics and charts > **Note:** > -> This section is not applicable to TiDB Cloud. +> This section is only applicable to on-premises TiDB. Currently, TiDB Cloud does not provide resource control metrics. -TiDB regularly collects runtime information about resource control and provides visual charts of the metrics in Grafana's **TiDB** > **Resource Control** panel. The metrics are detailed in the **Resource Control** section of [TiDB Important Monitoring Metrics](/grafana-tidb-dashboard.md). +TiDB regularly collects runtime information about resource control and provides visual charts of the metrics in Grafana's **TiDB** > **Resource Control** dashboard. The metrics are detailed in the **Resource Control** section of [TiDB Important Monitoring Metrics](/grafana-tidb-dashboard.md). + +TiKV also records the request QPS from different resource groups. For more details, see [TiKV Monitoring Metrics Detail](/grafana-tikv-dashboard.md#gRPC). ## Tool Compatibility -The resource control feature is still in its experimental stage and does not impact the regular usage of data import, export, and other replication tools. BR, TiDB Lightning, and TiCDC do not currently support resource control related DDL processing, and their resource consumption is not limited by resource control. +The resource control feature is still in its experimental stage and does not impact the regular usage of data import, export, and other replication tools. BR, TiDB Lightning, and TiCDC do not currently support processing DDL operations related to resource control, and their resource consumption is not limited by resource control. ## Limitations Currently, the resource control feature has the following limitations: -* This feature only supports restriction and scheduling of read and write requests initiated by frontend clients. It does not support restriction and scheduling of background tasks such as `DDL` and `Auto Analyze`. +* This feature only supports flow control and scheduling of read and write requests initiated by foreground clients. It does not support flow control and scheduling of background tasks such as DDL operations and auto analyze. * Resource control incurs additional scheduling overhead. Therefore, there might be a slight performance degradation when this feature is enabled. ## See also diff --git a/tikv-configuration-file.md b/tikv-configuration-file.md index be1df910b7c91..7737a0cd07b9f 100644 --- a/tikv-configuration-file.md +++ b/tikv-configuration-file.md @@ -2153,10 +2153,10 @@ To reduce write latency, TiKV periodically fetches and caches a batch of timesta ## resource-control -Configuration items related to resource control related to the TiKV storage layer. +Configuration items related to resource control of the TiKV storage layer. ### `enabled` New in v6.6.0 -+ Whether to support scheduling for user foreground read/write requests according to Request Unit (RU) of the corresponding resource group. For information about TiDB resource groups and resource control, see [TiDB resource control](/tidb-resource-control.md). -+ It is only meaningful to enable this configuration item if [`tidb_enable_resource_control](/system-variables.md#tidb_enable_resource_control-new-in-v660) is enabled on TiDB. When it is enabled, TiKV will use the priority queue to schedule the queued requests for user foreground read/write requests. The priority of scheduling is inversely related to the amount of resources already consumed by the resource group where the request is located, and positively related to the quota of the corresponding resource group. ++ Controls whether to enable scheduling for user foreground read/write requests according to [Request Unit (RU)](/tidb-resource-control.md#what-is-request-unit-ru) of the corresponding resource groups. For information about TiDB resource groups and resource control, see [TiDB resource control](/tidb-resource-control.md). ++ Enabling this configuration item only works when [`tidb_enable_resource_control](/system-variables.md#tidb_enable_resource_control-new-in-v660) is enabled on TiDB. When this configuration item is enabled, TiKV will use the priority queue to schedule the queued read/write requests from foreground users. The scheduling priority of a request is inversely related to the amount of resources already consumed by the resource group that receives this request, and positively related to the quota of the corresponding resource group. + Default value: `false`, which means to disable scheduling based on the RU of the resource group. \ No newline at end of file From c8edbda7e272747ef00c651673db5d1ca0d207a3 Mon Sep 17 00:00:00 2001 From: xixirangrang Date: Sat, 11 Feb 2023 22:36:59 +0800 Subject: [PATCH 39/63] Update grafana-resource-control-dashboard.md Co-authored-by: Grace Cai --- grafana-resource-control-dashboard.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grafana-resource-control-dashboard.md b/grafana-resource-control-dashboard.md index 1413e64cf71b4..a2dd9d8b05c72 100644 --- a/grafana-resource-control-dashboard.md +++ b/grafana-resource-control-dashboard.md @@ -24,7 +24,7 @@ This document describes some key monitoring metrics displayed on the Resource Co ## Metrics about resources -- KV Request Count: the number of KV requests is calculated in real time for each resource group. They are divided into read and write types. `total` is the sum of the KV requests involved by all Resource Groups. +- KV Request Count: the number of KV requests for each resource group, calculated per second. The requests are divided into read and write types. `total` is the sum of the KV requests for all Resource Groups. - KV Request Count Per Query: the average number of read and write KV requests by each SQL statement per second. It is obtained by dividing the above KV Request Count metric by the number of SQL statements executed per second. - Bytes Read: the amount of data read by each Resource Group, calculated per second. `total` is the sum of the data read by all Resource Groups. - Bytes Read Per Query: the average amount of data read by each SQL statement per second. It is obtained by dividing the above Bytes Read metric by the number of SQL statements executed per second. From 4ea89b47ac50abc733cffdcc3b950391abd64b73 Mon Sep 17 00:00:00 2001 From: xixirangrang Date: Sat, 11 Feb 2023 22:37:39 +0800 Subject: [PATCH 40/63] Apply suggestions from code review --- tidb-resource-control.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tidb-resource-control.md b/tidb-resource-control.md index dc709a535f14e..08d0dd0f56f27 100644 --- a/tidb-resource-control.md +++ b/tidb-resource-control.md @@ -16,8 +16,6 @@ The TiDB resource control feature provides two layers of resource management cap - TiDB flow control: TiDB flow control uses the [token bucket algorithm](https://en.wikipedia.org/wiki/Token_bucket). If there are not enough tokens in a bucket, and the resource group does not specify the `BURSTABLE` option, the requests to the resource group will wait for the token bucket to backfill the tokens and retry. The retry might fail due to timeout. - TiKV scheduling: if [`resource-control.enabled`](/tikv-configuration-file.md#resource-control) is enabled, TiKV uses the value of `RU_PER_SEC` of each resource group to determine the priority of the read and write requests for each resource group. Based on the priorities, the storage layer uses the priority queue to schedule and process requests. -The introduction of the resource control feature is a milestone for TiDB. It can divide a distributed database cluster into multiple logical units. Even if an individual unit overuses resources, it does not crowd out the resources needed by other units. - > **Note:** @@ -30,6 +28,8 @@ The introduction of the resource control feature is a milestone for TiDB. It can The introduction of the resource control feature is a milestone for TiDB. It can divide a distributed database cluster into multiple logical units. Even if an individual unit overuses resources, it does not crowd out the resources needed by other units. +The introduction of the resource control feature is a milestone for TiDB. It can divide a distributed database cluster into multiple logical units. Even if an individual unit overuses resources, it does not crowd out the resources needed by other units. + With this feature, you can: - Combine multiple small and medium-sized applications from different systems into a single TiDB cluster. When the workload of an application grows larger, it does not affect the normal operation of other applications. When the system workload is low, busy applications can still be allocated the required system resources even if they exceed the set read and write quotas, so as to achieve the maximum utilization of resources. @@ -156,6 +156,8 @@ TiDB regularly collects runtime information about resource control and provides TiKV also records the request QPS from different resource groups. For more details, see [TiKV Monitoring Metrics Detail](/grafana-tikv-dashboard.md#gRPC). +TiKV also records the request QPS from different resource groups. For more details, see [TiKV Monitoring Metrics Detail](/grafana-tikv-dashboard.md#gRPC). + ## Tool Compatibility The resource control feature is still in its experimental stage and does not impact the regular usage of data import, export, and other replication tools. BR, TiDB Lightning, and TiCDC do not currently support processing DDL operations related to resource control, and their resource consumption is not limited by resource control. From cccc9a21ab34e5865f4823767ca257f7bb8f5a1e Mon Sep 17 00:00:00 2001 From: xixirangrang <35301108+hfxsd@users.noreply.github.com> Date: Sat, 11 Feb 2023 22:38:16 +0800 Subject: [PATCH 41/63] Update grafana-tikv-dashboard.md --- grafana-tikv-dashboard.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/grafana-tikv-dashboard.md b/grafana-tikv-dashboard.md index e2b42fae80b97..666aa0696eca1 100644 --- a/grafana-tikv-dashboard.md +++ b/grafana-tikv-dashboard.md @@ -69,6 +69,9 @@ This section provides a detailed description of these key metrics on the **TiKV- - Average gRPC message duration: The average execution time of gRPC messages - gRPC batch size: The batch size of gRPC messages between TiDB and TiKV - Raft message batch size: The batch size of Raft messages between TiKV instances +- gRPC resource group duration: The QPS of gRPC request sources +- gRPC request sources duration: The execution time of gRPC request sources +- gRPC resource group QPS: The QPS of gRPC resource groups ### Thread CPU From 070ea083c54fde6c04170b5b5a9fc7743b910954 Mon Sep 17 00:00:00 2001 From: xixirangrang <35301108+hfxsd@users.noreply.github.com> Date: Sat, 11 Feb 2023 23:01:43 +0800 Subject: [PATCH 42/63] Update information-schema-processlist.md --- information-schema/information-schema-processlist.md | 1 + 1 file changed, 1 insertion(+) diff --git a/information-schema/information-schema-processlist.md b/information-schema/information-schema-processlist.md index 05724f5946b66..919ac63b9da20 100644 --- a/information-schema/information-schema-processlist.md +++ b/information-schema/information-schema-processlist.md @@ -48,6 +48,7 @@ DESC processlist; ```sql SELECT * FROM processlist\G ``` + ```sql *************************** 1. row *************************** ID: 2300033189772525975 From 235af051cecc7c41ad92f6161391ce7148e00bff Mon Sep 17 00:00:00 2001 From: xixirangrang <35301108+hfxsd@users.noreply.github.com> Date: Sun, 12 Feb 2023 10:22:46 +0800 Subject: [PATCH 43/63] Update sql-statement-drop-resource-group.md --- sql-statements/sql-statement-drop-resource-group.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql-statements/sql-statement-drop-resource-group.md b/sql-statements/sql-statement-drop-resource-group.md index 1ca96cf098efe..cf0d6c6acfac4 100644 --- a/sql-statements/sql-statement-drop-resource-group.md +++ b/sql-statements/sql-statement-drop-resource-group.md @@ -41,10 +41,10 @@ mysql> SELECT * FROM information_schema.resource_groups WHERE NAME ='rg1'; +------+------------+-----------+ 1 row in set (0.01 sec) -mysql> DROP RESOURCE GROUP IF EXISTS rg1 ; +mysql> DROP RESOURCE GROUP IF EXISTS rg1; Query OK, 1 rows affected (0.09 sec) -mysql> SELECT * FROM information_schema.resource_groups WHERE NAME ='rg1'; +mysql> SELECT * FROM information_schema.resource_groups WHERE NAME ='rg1'; Empty set (0.00 sec) ``` From 71c07b08732c8c932fb6245f291823c6537dedf6 Mon Sep 17 00:00:00 2001 From: xixirangrang <35301108+hfxsd@users.noreply.github.com> Date: Wed, 15 Feb 2023 16:01:10 +0800 Subject: [PATCH 44/63] add the note that this feature does not support serverless tier --- .../information-schema-resource-groups.md | 8 ++++++++ .../sql-statement-alter-resource-group.md | 8 ++++++++ .../sql-statement-create-resource-group.md | 8 ++++++++ .../sql-statement-drop-resource-group.md | 8 ++++++++ .../sql-statement-show-create-resource-group.md | 8 ++++++++ tidb-resource-control.md | 14 +++++++------- 6 files changed, 47 insertions(+), 7 deletions(-) diff --git a/information-schema/information-schema-resource-groups.md b/information-schema/information-schema-resource-groups.md index a2993c385a9d1..172b567281999 100644 --- a/information-schema/information-schema-resource-groups.md +++ b/information-schema/information-schema-resource-groups.md @@ -9,6 +9,14 @@ summary: Learn the `RESOURCE_GROUPS` information_schema table. > > This feature is experimental and its form and usage might change in subsequent versions. + + +> **Note:** +> +> This feature is not available on [Serverless Tier clusters](/tidb-cloud/select-cluster-tier.md#serverless-tier-beta). + + + The `RESOURCE_GROUPS` table shows the information about all resource groups. For more information, see [Use Resource Control to Achieve Resource Isolation](/tidb-resource-control.md). ```sql diff --git a/sql-statements/sql-statement-alter-resource-group.md b/sql-statements/sql-statement-alter-resource-group.md index 56df867d26a66..6a13caa1b058f 100644 --- a/sql-statements/sql-statement-alter-resource-group.md +++ b/sql-statements/sql-statement-alter-resource-group.md @@ -5,6 +5,14 @@ summary: Learn the usage of ALTER RESOURCE GROUP in TiDB. # ALTER RESOURCE GROUP + + +> **Note:** +> +> This feature is not available on [Serverless Tier clusters](/tidb-cloud/select-cluster-tier.md#serverless-tier-beta). + + + The `ALTER RESOURCE GROUP` statement is used to modify a resource group in a database. ## Synopsis diff --git a/sql-statements/sql-statement-create-resource-group.md b/sql-statements/sql-statement-create-resource-group.md index c721ff2fd5009..39ab52ac72e16 100644 --- a/sql-statements/sql-statement-create-resource-group.md +++ b/sql-statements/sql-statement-create-resource-group.md @@ -5,6 +5,14 @@ summary: Learn the usage of CREATE RESOURCE GROUP in TiDB. # CREATE RESOURCE GROUP + + +> **Note:** +> +> This feature is not available on [Serverless Tier clusters](/tidb-cloud/select-cluster-tier.md#serverless-tier-beta). + + + You can use the `CREATE RESOURCE GROUP` statement to create a resource group. ## Synopsis diff --git a/sql-statements/sql-statement-drop-resource-group.md b/sql-statements/sql-statement-drop-resource-group.md index cf0d6c6acfac4..2edd398c59be8 100644 --- a/sql-statements/sql-statement-drop-resource-group.md +++ b/sql-statements/sql-statement-drop-resource-group.md @@ -5,6 +5,14 @@ summary: Learn the usage of DROP RESOURCE GROUP in TiDB. # DROP RESOURCE GROUP + + +> **Note:** +> +> This feature is not available on [Serverless Tier clusters](/tidb-cloud/select-cluster-tier.md#serverless-tier-beta). + + + You can use the `DROP RESOURCE GROUP` statement to drop a resource group. ## Synopsis diff --git a/sql-statements/sql-statement-show-create-resource-group.md b/sql-statements/sql-statement-show-create-resource-group.md index 9b3cc33927338..ab3523a14df24 100644 --- a/sql-statements/sql-statement-show-create-resource-group.md +++ b/sql-statements/sql-statement-show-create-resource-group.md @@ -5,6 +5,14 @@ summary: Learn the usage of SHOW CREATE RESOURCE GROUP in TiDB. # SHOW CREATE RESOURCE GROUP + + +> **Note:** +> +> This feature is not available on [Serverless Tier clusters](/tidb-cloud/select-cluster-tier.md#serverless-tier-beta). + + + You can use the `SHOW CREATE RESOURCE GROUP` statement to view the current definition of a resource group. ## Synopsis diff --git a/tidb-resource-control.md b/tidb-resource-control.md index 08d0dd0f56f27..215aa823d6ec1 100644 --- a/tidb-resource-control.md +++ b/tidb-resource-control.md @@ -9,13 +9,6 @@ summary: Learn how to use the resource control feature to control and schedule a > > This feature is experimental and its form and usage might change in subsequent versions. -As a cluster administrator, you can use the resource control feature to create resource groups, set read and write quotas for resource groups, and bind users to those groups. This allows the TiDB layer to control the flow of user read and write requests based on the quotas set for the resource groups, and allows the TiKV layer to schedule the requests based on the priority mapped to the read and write quota. By doing this, you can ensure resource isolation for your applications and meet quality of service (QoS) requirements. - -The TiDB resource control feature provides two layers of resource management capabilities: the flow control capability at the TiDB layer and the priority scheduling capability at the TiKV layer. The two capabilities can be enabled separately or simultaneously. See the [Parameters for resource control](#parameters-for-resource-control) for details. - -- TiDB flow control: TiDB flow control uses the [token bucket algorithm](https://en.wikipedia.org/wiki/Token_bucket). If there are not enough tokens in a bucket, and the resource group does not specify the `BURSTABLE` option, the requests to the resource group will wait for the token bucket to backfill the tokens and retry. The retry might fail due to timeout. -- TiKV scheduling: if [`resource-control.enabled`](/tikv-configuration-file.md#resource-control) is enabled, TiKV uses the value of `RU_PER_SEC` of each resource group to determine the priority of the read and write requests for each resource group. Based on the priorities, the storage layer uses the priority queue to schedule and process requests. - > **Note:** @@ -24,6 +17,13 @@ The TiDB resource control feature provides two layers of resource management cap +As a cluster administrator, you can use the resource control feature to create resource groups, set read and write quotas for resource groups, and bind users to those groups. This allows the TiDB layer to control the flow of user read and write requests based on the quotas set for the resource groups, and allows the TiKV layer to schedule the requests based on the priority mapped to the read and write quota. By doing this, you can ensure resource isolation for your applications and meet quality of service (QoS) requirements. + +The TiDB resource control feature provides two layers of resource management capabilities: the flow control capability at the TiDB layer and the priority scheduling capability at the TiKV layer. The two capabilities can be enabled separately or simultaneously. See the [Parameters for resource control](#parameters-for-resource-control) for details. + +- TiDB flow control: TiDB flow control uses the [token bucket algorithm](https://en.wikipedia.org/wiki/Token_bucket). If there are not enough tokens in a bucket, and the resource group does not specify the `BURSTABLE` option, the requests to the resource group will wait for the token bucket to backfill the tokens and retry. The retry might fail due to timeout. +- TiKV scheduling: if [`resource-control.enabled`](/tikv-configuration-file.md#resource-control) is enabled, TiKV uses the value of `RU_PER_SEC` of each resource group to determine the priority of the read and write requests for each resource group. Based on the priorities, the storage layer uses the priority queue to schedule and process requests. + ## Scenarios for resource control The introduction of the resource control feature is a milestone for TiDB. It can divide a distributed database cluster into multiple logical units. Even if an individual unit overuses resources, it does not crowd out the resources needed by other units. From 7b6e581ccdf462ad257d505bf8c936a993de655a Mon Sep 17 00:00:00 2001 From: xixirangrang <35301108+hfxsd@users.noreply.github.com> Date: Wed, 15 Feb 2023 21:53:06 +0800 Subject: [PATCH 45/63] Update tidb-resource-control.md --- tidb-resource-control.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tidb-resource-control.md b/tidb-resource-control.md index 215aa823d6ec1..029dc5c141c5e 100644 --- a/tidb-resource-control.md +++ b/tidb-resource-control.md @@ -77,6 +77,8 @@ The results of the combinations of these two parameters are shown in the followi | `resource-control.enabled`= true | Flow control and scheduling (recommended) | Invalid combination | | `resource-control.enabled`= false | Only flow control (not recommended) | The feature is disabled. | +For more information about the resource control mechanism, see [RFC: Global Resource Control in TiDB](https://docs.google.com/document/d/1sV5EVv8Cdpc6aBCDihc2akpE0iuantPf/edit?n= RFC_Global_Resource_Control_in_TiDB.docx#heading=h.sjp9cmjfszlu). + ## How to use resource control To create, modify, or delete a resource group, you need to have the `SUPER` or `RESOURCE_GROUP_ADMIN` privilege. From 0923d0b4dee121981a7ec6586fd987cc74828301 Mon Sep 17 00:00:00 2001 From: xixirangrang Date: Wed, 15 Feb 2023 22:03:56 +0800 Subject: [PATCH 46/63] Apply suggestions from code review Co-authored-by: Grace Cai --- grafana-resource-control-dashboard.md | 2 +- grafana-tikv-dashboard.md | 4 ++-- tidb-resource-control.md | 2 -- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/grafana-resource-control-dashboard.md b/grafana-resource-control-dashboard.md index a2dd9d8b05c72..e1437e348450c 100644 --- a/grafana-resource-control-dashboard.md +++ b/grafana-resource-control-dashboard.md @@ -19,7 +19,7 @@ This document describes some key monitoring metrics displayed on the Resource Co - RU Per Query: the average number of Request Units consumed by each SQL statement per second. It is obtained by dividing the above RU metric by the number of SQL statements executed per second. - RRU: the Read Request Unit consumption information of each resource group, calculated in real time. `total` is the sum of the Read Request Units consumed by all Resource Groups. - RRU Per Query: the average number of Read Request Units consumed by each SQL statement per second. It is obtained by dividing the above RRU metric by the number of SQL statements executed per second. -- WRU: the Write Request Unit consumption information of each resource group, calculated in real time. `total` is the sum of the Write Request Units consumed by all Resource Groups. +- WRU: the Write Request Unit consumption information of each resource group, calculated in real time. `total` is the sum of the Write Request Units consumed by all Resource Groups. - WRU Per Query: the average number of Write Request Units consumed by each SQL statement per second. It is obtained by dividing the above WRU metric by the number of SQL statements executed per second. ## Metrics about resources diff --git a/grafana-tikv-dashboard.md b/grafana-tikv-dashboard.md index 666aa0696eca1..20eb34b4f4e21 100644 --- a/grafana-tikv-dashboard.md +++ b/grafana-tikv-dashboard.md @@ -69,9 +69,9 @@ This section provides a detailed description of these key metrics on the **TiKV- - Average gRPC message duration: The average execution time of gRPC messages - gRPC batch size: The batch size of gRPC messages between TiDB and TiKV - Raft message batch size: The batch size of Raft messages between TiKV instances -- gRPC resource group duration: The QPS of gRPC request sources +- gRPC request sources QPS: The QPS of gRPC request sources - gRPC request sources duration: The execution time of gRPC request sources -- gRPC resource group QPS: The QPS of gRPC resource groups +- gRPC resource group QPS: The QPS of gRPC request sources by resource groups ### Thread CPU diff --git a/tidb-resource-control.md b/tidb-resource-control.md index 029dc5c141c5e..d5c7973cff8e0 100644 --- a/tidb-resource-control.md +++ b/tidb-resource-control.md @@ -158,8 +158,6 @@ TiDB regularly collects runtime information about resource control and provides TiKV also records the request QPS from different resource groups. For more details, see [TiKV Monitoring Metrics Detail](/grafana-tikv-dashboard.md#gRPC). -TiKV also records the request QPS from different resource groups. For more details, see [TiKV Monitoring Metrics Detail](/grafana-tikv-dashboard.md#gRPC). - ## Tool Compatibility The resource control feature is still in its experimental stage and does not impact the regular usage of data import, export, and other replication tools. BR, TiDB Lightning, and TiCDC do not currently support processing DDL operations related to resource control, and their resource consumption is not limited by resource control. From cefd18ec71672292c7d7374a62938ba4014b66cd Mon Sep 17 00:00:00 2001 From: xixirangrang Date: Wed, 15 Feb 2023 22:24:39 +0800 Subject: [PATCH 47/63] Update tidb-resource-control.md --- tidb-resource-control.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/tidb-resource-control.md b/tidb-resource-control.md index d5c7973cff8e0..197cce81d47c6 100644 --- a/tidb-resource-control.md +++ b/tidb-resource-control.md @@ -28,8 +28,6 @@ The TiDB resource control feature provides two layers of resource management cap The introduction of the resource control feature is a milestone for TiDB. It can divide a distributed database cluster into multiple logical units. Even if an individual unit overuses resources, it does not crowd out the resources needed by other units. -The introduction of the resource control feature is a milestone for TiDB. It can divide a distributed database cluster into multiple logical units. Even if an individual unit overuses resources, it does not crowd out the resources needed by other units. - With this feature, you can: - Combine multiple small and medium-sized applications from different systems into a single TiDB cluster. When the workload of an application grows larger, it does not affect the normal operation of other applications. When the system workload is low, busy applications can still be allocated the required system resources even if they exceed the set read and write quotas, so as to achieve the maximum utilization of resources. From 155f79164003e61891a2fcc355e6260260a728c2 Mon Sep 17 00:00:00 2001 From: xixirangrang Date: Wed, 15 Feb 2023 22:27:11 +0800 Subject: [PATCH 48/63] Update tidb-resource-control.md --- tidb-resource-control.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tidb-resource-control.md b/tidb-resource-control.md index 197cce81d47c6..3a3ad72586252 100644 --- a/tidb-resource-control.md +++ b/tidb-resource-control.md @@ -58,7 +58,7 @@ Based on the above table, assuming that the TiKV time consumed by a resource gro The resource control feature introduces two new global variables. * TiDB: you can use the [`tidb_enable_resource_control`](/system-variables.md#tidb-tidb_enable_resource_control-new-in-v660) system variable to control whether to enable flow control for resource groups. -* TiKV: you can use the [`resource-control.enabled`](/tikv-configuration-file.md#resource-control) parameter to control whether to use request scheduling based on resource group quotas. +* TiKV: you can use the [`resource-control.enabled`](/tikv-configuration-file.md#resource-control) parameter to control whether to use request scheduling based on resource groups. From 0f7a666514a2d7bdbcc0a5b255b297d9bbf3bd2c Mon Sep 17 00:00:00 2001 From: xixirangrang Date: Wed, 15 Feb 2023 22:35:04 +0800 Subject: [PATCH 49/63] Apply suggestions from code review --- tidb-resource-control.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tidb-resource-control.md b/tidb-resource-control.md index 3a3ad72586252..a9d754cfab8fb 100644 --- a/tidb-resource-control.md +++ b/tidb-resource-control.md @@ -64,7 +64,7 @@ The resource control feature introduces two new global variables. > **Note:** > -> In TiDB Cloud, the value of the `resource-control.enabled` parameter is `false` by default and does not support dynamic modification. If you need to enable it for TiDB Cloud Dedicated Tier clusters, contact [TiDB Cloud Support](/tidb-cloud/tidb-cloud-support.md). +> In TiDB Cloud, the value of the `resource-control.enabled` parameter is `false` by default and does not support dynamic modification. If you need to enable it for TiDB Cloud Dedicated Tier clusters, contact [TiDB Cloud Support](/tidb-cloud/tidb-cloud-support.md). @@ -83,7 +83,7 @@ To create, modify, or delete a resource group, you need to have the `SUPER` or ` You can create a resource group in the cluster by using [`CREATE RESOURCE GROUP`](/sql-statements/sql-statement-create-resource-group.md), and then bind users to a specific resource group by using [`CREATE USER`](/sql-statements/ sql-statement-create-user.md) or [`ALTER USER`](/sql-statements/sql-statement-alter-user.md). -For an existing resource group, you can modify the read and write quota of the resource group by using [`ALTER RESOURCE GROUP`](/sql-statements/sql-statement-alter-resource-group.md). The quota changes to the resource group take effect immediately. +For an existing resource group, you can modify the `RU_PER_SEC` option (the rate of RU backfilling per second) of the resource group by using [`ALTER RESOURCE GROUP`](/sql-statements/sql-statement-alter-resource-group.md). The changes to the resource group take effect immediately. You can delete a resource group by using [`DROP RESOURCE GROUP`](/sql-statements/sql-statement-drop-resource-group.md). From fa3e83d2430346dbd3fae1239158b3fef1f4fda7 Mon Sep 17 00:00:00 2001 From: xixirangrang Date: Thu, 16 Feb 2023 10:10:27 +0800 Subject: [PATCH 50/63] Update tidb-resource-control.md --- tidb-resource-control.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tidb-resource-control.md b/tidb-resource-control.md index a9d754cfab8fb..83948d1118d2e 100644 --- a/tidb-resource-control.md +++ b/tidb-resource-control.md @@ -75,7 +75,7 @@ The results of the combinations of these two parameters are shown in the followi | `resource-control.enabled`= true | Flow control and scheduling (recommended) | Invalid combination | | `resource-control.enabled`= false | Only flow control (not recommended) | The feature is disabled. | -For more information about the resource control mechanism, see [RFC: Global Resource Control in TiDB](https://docs.google.com/document/d/1sV5EVv8Cdpc6aBCDihc2akpE0iuantPf/edit?n= RFC_Global_Resource_Control_in_TiDB.docx#heading=h.sjp9cmjfszlu). +For more information about the resource control mechanism and parameters, see [RFC: Global Resource Control in TiDB](https://docs.google.com/document/d/1sV5EVv8Cdpc6aBCDihc2akpE0iuantPf/edit?n= RFC_Global_Resource_Control_in_TiDB.docx#heading=h.sjp9cmjfszlu). ## How to use resource control From 7a59a5bd14f4996315df262dcabf0b196410d328 Mon Sep 17 00:00:00 2001 From: BornChanger <97348524+BornChanger@users.noreply.github.com> Date: Thu, 16 Feb 2023 16:52:32 +0800 Subject: [PATCH 51/63] Update information-schema/information-schema-resource-groups.md --- information-schema/information-schema-resource-groups.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/information-schema/information-schema-resource-groups.md b/information-schema/information-schema-resource-groups.md index 172b567281999..260c65b653037 100644 --- a/information-schema/information-schema-resource-groups.md +++ b/information-schema/information-schema-resource-groups.md @@ -32,7 +32,7 @@ DESC resource_groups; | RU_PER_SEC | bigint(21) | YES | | NULL | | | BURSTABLE | varchar(3) | YES | | NULL | | +------------+-------------+------+------+---------+-------+ -4 rows in set (0.00 sec) +3 rows in set (0.00 sec) ``` ## Examples From b21d6b7ac6d346fcbd745cd799d67875b929c6be Mon Sep 17 00:00:00 2001 From: BornChanger <97348524+BornChanger@users.noreply.github.com> Date: Thu, 16 Feb 2023 16:53:14 +0800 Subject: [PATCH 52/63] Update information-schema/information-schema-resource-groups.md --- information-schema/information-schema-resource-groups.md | 1 + 1 file changed, 1 insertion(+) diff --git a/information-schema/information-schema-resource-groups.md b/information-schema/information-schema-resource-groups.md index 260c65b653037..8b094de03661e 100644 --- a/information-schema/information-schema-resource-groups.md +++ b/information-schema/information-schema-resource-groups.md @@ -53,6 +53,7 @@ mysql> SELECT * FROM information_schema.resource_groups WHERE NAME = 'rg1'; +------+------------+-----------+ | rg1 | 1000 | NO | +------+------------+-----------+ +1 row in set (0.00 sec) ``` The descriptions of the columns in the `RESOURCE_GROUPS` table are as follows: From 6c6de80b2ff45d20c3cf9eb64e301abefc7d2bc2 Mon Sep 17 00:00:00 2001 From: BornChanger <97348524+BornChanger@users.noreply.github.com> Date: Thu, 16 Feb 2023 16:58:30 +0800 Subject: [PATCH 53/63] Update sql-statements/sql-statement-alter-resource-group.md --- sql-statements/sql-statement-alter-resource-group.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql-statements/sql-statement-alter-resource-group.md b/sql-statements/sql-statement-alter-resource-group.md index 6a13caa1b058f..406691259e5cf 100644 --- a/sql-statements/sql-statement-alter-resource-group.md +++ b/sql-statements/sql-statement-alter-resource-group.md @@ -19,7 +19,7 @@ The `ALTER RESOURCE GROUP` statement is used to modify a resource group in a dat ```ebnf+diagram AlterResourceGroupStmt: - "ALTER" "RESOURCE" "GROUP" IfNotExists ResourceGroupName ResourceGroupOptionList + "ALTER" "RESOURCE" "GROUP" IfExists ResourceGroupName ResourceGroupOptionList IfNotExists ::= ('IF' 'EXISTS')? From 2d1f36d94ba4132a6b12ba2e4df1b4551327f160 Mon Sep 17 00:00:00 2001 From: BornChanger <97348524+BornChanger@users.noreply.github.com> Date: Thu, 16 Feb 2023 16:58:42 +0800 Subject: [PATCH 54/63] Update sql-statements/sql-statement-alter-resource-group.md --- sql-statements/sql-statement-alter-resource-group.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql-statements/sql-statement-alter-resource-group.md b/sql-statements/sql-statement-alter-resource-group.md index 406691259e5cf..088f2b5759abe 100644 --- a/sql-statements/sql-statement-alter-resource-group.md +++ b/sql-statements/sql-statement-alter-resource-group.md @@ -21,7 +21,7 @@ The `ALTER RESOURCE GROUP` statement is used to modify a resource group in a dat AlterResourceGroupStmt: "ALTER" "RESOURCE" "GROUP" IfExists ResourceGroupName ResourceGroupOptionList -IfNotExists ::= +IfExists ::= ('IF' 'EXISTS')? ResourceGroupName: From 5e1fd624e4bbbdee71e3f689a45ef82323c6c6e5 Mon Sep 17 00:00:00 2001 From: xixirangrang Date: Fri, 17 Feb 2023 09:07:41 +0800 Subject: [PATCH 55/63] Apply suggestions from code review Co-authored-by: Grace Cai --- tidb-resource-control.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tidb-resource-control.md b/tidb-resource-control.md index 83948d1118d2e..c07d055ea03db 100644 --- a/tidb-resource-control.md +++ b/tidb-resource-control.md @@ -140,7 +140,7 @@ The following is an example of how to create a resource group and bind users to After you complete the above operations of creating resource groups and binding users, the resource consumption of newly created sessions will be controlled by the specified quota. If the system workload is relatively high and there is no spare capacity, the resource consumption rate of `usr2` will be strictly controlled not to exceed the quota. Because `usr1` is bound by `rg1` with `BURSTABLE` configured, the consumption rate of `usr1` is allowed to exceed the quota. -If the resource group corresponds to a request with insufficient quota, the client's request will wait. If the wait time is too long, the request will report an error. +If the resource group corresponds to a request with an insufficient quota, the client's request will wait. If the wait time is too long, the request will report an error. ## Monitoring metrics and charts @@ -156,7 +156,7 @@ TiDB regularly collects runtime information about resource control and provides TiKV also records the request QPS from different resource groups. For more details, see [TiKV Monitoring Metrics Detail](/grafana-tikv-dashboard.md#gRPC). -## Tool Compatibility +## Tool compatibility The resource control feature is still in its experimental stage and does not impact the regular usage of data import, export, and other replication tools. BR, TiDB Lightning, and TiCDC do not currently support processing DDL operations related to resource control, and their resource consumption is not limited by resource control. From 1c63af5bb218c511f26051e77203a73722ad79c8 Mon Sep 17 00:00:00 2001 From: xixirangrang Date: Fri, 17 Feb 2023 11:02:40 +0800 Subject: [PATCH 56/63] Apply suggestions from code review --- tidb-resource-control.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tidb-resource-control.md b/tidb-resource-control.md index c07d055ea03db..1843fbe16c67c 100644 --- a/tidb-resource-control.md +++ b/tidb-resource-control.md @@ -90,7 +90,7 @@ You can delete a resource group by using [`DROP RESOURCE GROUP`](/sql-statements > **Note:** > > - When you bind a user to a resource group by using `CREATE USER` or `ALTER USER`, it will not take effect for the user's existing sessions, but only for the user's new sessions. -> - If a user is not bound to a resource group or is bound to a `default` resource group, the user's requests are not subject to the flow control restrictions of TiDB. The `default` resource group is currently not visible to the user and cannot be created or modified. +> - If a user is not bound to a resource group or is bound to a `default` resource group, the user's requests are not subject to the flow control restrictions of TiDB. The `default` resource group is currently not visible to the user and cannot be created or modified. You cannot view it with `SHOW CREATE RESOURCE GROUP` or `SELECT * FROM information_schema.resource_groups`. But you can view it through the `mysql.user` table. ### Step 1. Enable the resource control feature @@ -140,7 +140,7 @@ The following is an example of how to create a resource group and bind users to After you complete the above operations of creating resource groups and binding users, the resource consumption of newly created sessions will be controlled by the specified quota. If the system workload is relatively high and there is no spare capacity, the resource consumption rate of `usr2` will be strictly controlled not to exceed the quota. Because `usr1` is bound by `rg1` with `BURSTABLE` configured, the consumption rate of `usr1` is allowed to exceed the quota. -If the resource group corresponds to a request with an insufficient quota, the client's request will wait. If the wait time is too long, the request will report an error. +If there are too many requests that result in insufficient resources for the resource group, the client's requests will wait. If the wait time is too long, the requests will report an error. ## Monitoring metrics and charts From 22e2cd1455f33096fcb38d1d18d336e8d15018d9 Mon Sep 17 00:00:00 2001 From: xixirangrang <35301108+hfxsd@users.noreply.github.com> Date: Fri, 17 Feb 2023 11:15:55 +0800 Subject: [PATCH 57/63] Update TOC-tidb-cloud.md --- TOC-tidb-cloud.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/TOC-tidb-cloud.md b/TOC-tidb-cloud.md index dda16cb26a4e9..4df944f568cab 100644 --- a/TOC-tidb-cloud.md +++ b/TOC-tidb-cloud.md @@ -98,6 +98,7 @@ - [Scale a TiDB Cluster](/tidb-cloud/scale-tidb-cluster.md) - [Pause or Resume a TiDB Cluster](/tidb-cloud/pause-or-resume-tidb-cluster.md) - [Upgrade a TiDB Cluster](/tidb-cloud/upgrade-tidb-cluster.md) + - [Resource Control](/tidb-resource-control.md) - [Delete a TiDB Cluster](/tidb-cloud/delete-tidb-cluster.md) - Migrate or Import Data - [Overview](/tidb-cloud/tidb-cloud-migration-overview.md) @@ -254,6 +255,7 @@ - [`ADMIN SHOW DDL [JOBS|JOB QUERIES]`](/sql-statements/sql-statement-admin-show-ddl.md) - [`ALTER DATABASE`](/sql-statements/sql-statement-alter-database.md) - [`ALTER INDEX`](/sql-statements/sql-statement-alter-index.md) + - [`ALTER RESOURCE GROUP`](/sql-statements/sql-statement-alter-resource-group.md) - [`ALTER TABLE`](/sql-statements/sql-statement-alter-table.md) - [`ALTER TABLE COMPACT`](/sql-statements/sql-statement-alter-table-compact.md) - [`ALTER USER`](/sql-statements/sql-statement-alter-user.md) @@ -267,6 +269,7 @@ - [`CREATE [GLOBAL|SESSION] BINDING`](/sql-statements/sql-statement-create-binding.md) - [`CREATE DATABASE`](/sql-statements/sql-statement-create-database.md) - [`CREATE INDEX`](/sql-statements/sql-statement-create-index.md) + - [`CREATE RESOURCE GROUP`](/sql-statements/sql-statement-create-resource-group.md) - [`CREATE ROLE`](/sql-statements/sql-statement-create-role.md) - [`CREATE SEQUENCE`](/sql-statements/sql-statement-create-sequence.md) - [`CREATE TABLE LIKE`](/sql-statements/sql-statement-create-table-like.md) @@ -282,6 +285,7 @@ - [`DROP COLUMN`](/sql-statements/sql-statement-drop-column.md) - [`DROP DATABASE`](/sql-statements/sql-statement-drop-database.md) - [`DROP INDEX`](/sql-statements/sql-statement-drop-index.md) + - [`DROP RESOURCE GROUP`](/sql-statements/sql-statement-drop-resource-group.md) - [`DROP ROLE`](/sql-statements/sql-statement-drop-role.md) - [`DROP SEQUENCE`](/sql-statements/sql-statement-drop-sequence.md) - [`DROP STATS`](/sql-statements/sql-statement-drop-stats.md) @@ -327,6 +331,7 @@ - [`SHOW COLLATION`](/sql-statements/sql-statement-show-collation.md) - [`SHOW [FULL] COLUMNS FROM`](/sql-statements/sql-statement-show-columns-from.md) - [`SHOW CREATE DATABASE`](/sql-statements/sql-statement-show-create-database.md) + - [`SHOW CREATE RESOURCE GROUP`](/sql-statements/sql-statement-show-create-resource-group.md) - [`SHOW CREATE SEQUENCE`](/sql-statements/sql-statement-show-create-sequence.md) - [`SHOW CREATE TABLE`](/sql-statements/sql-statement-show-create-table.md) - [`SHOW CREATE USER`](/sql-statements/sql-statement-show-create-user.md) @@ -444,6 +449,7 @@ - [`PARTITIONS`](/information-schema/information-schema-partitions.md) - [`PROCESSLIST`](/information-schema/information-schema-processlist.md) - [`REFERENTIAL_CONSTRAINTS`](/information-schema/information-schema-referential-constraints.md) + - [`RESOURCE_GROUPS`](/information-schema/information-schema-resource-groups.md) - [`SCHEMATA`](/information-schema/information-schema-schemata.md) - [`SEQUENCES`](/information-schema/information-schema-sequences.md) - [`SESSION_VARIABLES`](/information-schema/information-schema-session-variables.md) From c7b13a10fbe57e037cc6b90c411e0360f753024e Mon Sep 17 00:00:00 2001 From: xixirangrang <35301108+hfxsd@users.noreply.github.com> Date: Fri, 17 Feb 2023 11:33:53 +0800 Subject: [PATCH 58/63] Update TOC-tidb-cloud.md --- TOC-tidb-cloud.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TOC-tidb-cloud.md b/TOC-tidb-cloud.md index 4df944f568cab..522afa658bc43 100644 --- a/TOC-tidb-cloud.md +++ b/TOC-tidb-cloud.md @@ -98,7 +98,6 @@ - [Scale a TiDB Cluster](/tidb-cloud/scale-tidb-cluster.md) - [Pause or Resume a TiDB Cluster](/tidb-cloud/pause-or-resume-tidb-cluster.md) - [Upgrade a TiDB Cluster](/tidb-cloud/upgrade-tidb-cluster.md) - - [Resource Control](/tidb-resource-control.md) - [Delete a TiDB Cluster](/tidb-cloud/delete-tidb-cluster.md) - Migrate or Import Data - [Overview](/tidb-cloud/tidb-cloud-migration-overview.md) @@ -483,6 +482,7 @@ - [Table Filter](/table-filter.md) - [Troubleshoot Inconsistency Between Data and Indexes](/troubleshoot-data-inconsistency-errors.md) - [Serverless Tier Limitations](/tidb-cloud/serverless-tier-limitations.md) + - [Resource Control](/tidb-resource-control.md) - FAQs - [TiDB Cloud FAQs](/tidb-cloud/tidb-cloud-faq.md) - [Serverless Tier FAQs](/tidb-cloud/serverless-tier-faqs.md) From 3ddf4a98965c62a3b76f8a02a08216d1c680c804 Mon Sep 17 00:00:00 2001 From: xixirangrang <35301108+hfxsd@users.noreply.github.com> Date: Fri, 17 Feb 2023 11:39:14 +0800 Subject: [PATCH 59/63] Update tidb-resource-control.md --- tidb-resource-control.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tidb-resource-control.md b/tidb-resource-control.md index 1843fbe16c67c..a6ea11ff5f940 100644 --- a/tidb-resource-control.md +++ b/tidb-resource-control.md @@ -75,7 +75,7 @@ The results of the combinations of these two parameters are shown in the followi | `resource-control.enabled`= true | Flow control and scheduling (recommended) | Invalid combination | | `resource-control.enabled`= false | Only flow control (not recommended) | The feature is disabled. | -For more information about the resource control mechanism and parameters, see [RFC: Global Resource Control in TiDB](https://docs.google.com/document/d/1sV5EVv8Cdpc6aBCDihc2akpE0iuantPf/edit?n= RFC_Global_Resource_Control_in_TiDB.docx#heading=h.sjp9cmjfszlu). +For more information about the resource control mechanism and parameters, see [RFC: Global Resource Control in TiDB](https://docs.google.com/document/d/1sV5EVv8Cdpc6aBCDihc2akpE0iuantPf/edit?n=RFC_Global_Resource_Control_in_TiDB.docx#heading=h.sjp9cmjfszlu). ## How to use resource control From 12e8dc417a9146a6457cfeeed9ba6ef66c5d5061 Mon Sep 17 00:00:00 2001 From: xixirangrang <35301108+hfxsd@users.noreply.github.com> Date: Fri, 17 Feb 2023 11:49:21 +0800 Subject: [PATCH 60/63] Update grafana-resource-control-dashboard.md --- grafana-resource-control-dashboard.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grafana-resource-control-dashboard.md b/grafana-resource-control-dashboard.md index e1437e348450c..fd4002f75078a 100644 --- a/grafana-resource-control-dashboard.md +++ b/grafana-resource-control-dashboard.md @@ -9,7 +9,7 @@ If you use TiUP to deploy the TiDB cluster, the monitoring system (Prometheus & The Grafana dashboard is divided into a series of sub dashboards which include Overview, PD, TiDB, TiKV, Node\_exporter, Disk Performance, and Performance\_overview. -If your cluster has used the [Resource Control](tidb-resource-control.md) feature, you can get an overview of the resource consumption status from the Resource Control dashboard. +If your cluster has used the [Resource Control](/tidb-resource-control.md) feature, you can get an overview of the resource consumption status from the Resource Control dashboard. This document describes some key monitoring metrics displayed on the Resource Control dashboard. From c7fd54ece5afd73f87bf8056c8778289c4266fcf Mon Sep 17 00:00:00 2001 From: xixirangrang <35301108+hfxsd@users.noreply.github.com> Date: Fri, 17 Feb 2023 11:54:14 +0800 Subject: [PATCH 61/63] Update grafana-resource-control-dashboard.md --- grafana-resource-control-dashboard.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grafana-resource-control-dashboard.md b/grafana-resource-control-dashboard.md index fd4002f75078a..c75719342b2b3 100644 --- a/grafana-resource-control-dashboard.md +++ b/grafana-resource-control-dashboard.md @@ -9,7 +9,7 @@ If you use TiUP to deploy the TiDB cluster, the monitoring system (Prometheus & The Grafana dashboard is divided into a series of sub dashboards which include Overview, PD, TiDB, TiKV, Node\_exporter, Disk Performance, and Performance\_overview. -If your cluster has used the [Resource Control](/tidb-resource-control.md) feature, you can get an overview of the resource consumption status from the Resource Control dashboard. +If your cluster has used the [Resource Control](/tidb-resource-control.md) feature, you can get an overview of the resource consumption status from the Resource Control dashboard. This document describes some key monitoring metrics displayed on the Resource Control dashboard. From d84412f7fee8357d9015a76c02732b5b87e1bd81 Mon Sep 17 00:00:00 2001 From: Grace Cai Date: Fri, 17 Feb 2023 13:38:00 +0800 Subject: [PATCH 62/63] add the customcontent for TiDB Cloud --- tidb-resource-control.md | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/tidb-resource-control.md b/tidb-resource-control.md index a6ea11ff5f940..327977c58fc52 100644 --- a/tidb-resource-control.md +++ b/tidb-resource-control.md @@ -22,8 +22,19 @@ As a cluster administrator, you can use the resource control feature to create r The TiDB resource control feature provides two layers of resource management capabilities: the flow control capability at the TiDB layer and the priority scheduling capability at the TiKV layer. The two capabilities can be enabled separately or simultaneously. See the [Parameters for resource control](#parameters-for-resource-control) for details. - TiDB flow control: TiDB flow control uses the [token bucket algorithm](https://en.wikipedia.org/wiki/Token_bucket). If there are not enough tokens in a bucket, and the resource group does not specify the `BURSTABLE` option, the requests to the resource group will wait for the token bucket to backfill the tokens and retry. The retry might fail due to timeout. + + + - TiKV scheduling: if [`resource-control.enabled`](/tikv-configuration-file.md#resource-control) is enabled, TiKV uses the value of `RU_PER_SEC` of each resource group to determine the priority of the read and write requests for each resource group. Based on the priorities, the storage layer uses the priority queue to schedule and process requests. + + + + +- TiKV scheduling: for on-premises TiDB, if the `resource-control.enabled` parameter is enabled, TiKV uses the value of `RU_PER_SEC` of each resource group to determine the priority of the read and write requests for each resource group. Based on the priorities, the storage layer uses the priority queue to schedule and process requests. For TiDB Cloud, the value of the `resource-control.enabled` parameter is `false` by default and does not support dynamic modification. If you need to enable it for TiDB Cloud Dedicated Tier clusters, contact [TiDB Cloud Support](/tidb-cloud/tidb-cloud-support.md). + + + ## Scenarios for resource control The introduction of the resource control feature is a milestone for TiDB. It can divide a distributed database cluster into multiple logical units. Even if an individual unit overuses resources, it does not crowd out the resources needed by other units. @@ -58,13 +69,16 @@ Based on the above table, assuming that the TiKV time consumed by a resource gro The resource control feature introduces two new global variables. * TiDB: you can use the [`tidb_enable_resource_control`](/system-variables.md#tidb-tidb_enable_resource_control-new-in-v660) system variable to control whether to enable flow control for resource groups. + + + * TiKV: you can use the [`resource-control.enabled`](/tikv-configuration-file.md#resource-control) parameter to control whether to use request scheduling based on resource groups. + + -> **Note:** -> -> In TiDB Cloud, the value of the `resource-control.enabled` parameter is `false` by default and does not support dynamic modification. If you need to enable it for TiDB Cloud Dedicated Tier clusters, contact [TiDB Cloud Support](/tidb-cloud/tidb-cloud-support.md). +* TiKV: For on-premises TiDB, you can use the `resource-control.enabled` parameter to control whether to use request scheduling based on resource group quotas. For TiDB Cloud, the value of the `resource-control.enabled` parameter is `false` by default and does not support dynamic modification. If you need to enable it for TiDB Cloud Dedicated Tier clusters, contact [TiDB Cloud Support](/tidb-cloud/tidb-cloud-support.md). @@ -108,7 +122,7 @@ Set the TiKV [`resource-control.enabled`](/tikv-configuration-file.md#resource-c -In TiKV, set the parameter [`resource-control.enabled`](https://docs.pingcap.com/tidb/stable/tikv-configuration-file#resource_control) to `true`. The parameter `resource-control.enabled` is disabled by default. You need to contact the [PingCAP support team](/tidb-cloud/tidb-cloud-support.md) to enable it. +For on-premises TiDB, set the TiKV `resource-control.enabled` parameter to `true`. For TiDB Cloud, the value of the `resource-control.enabled` parameter is `false` by default and does not support dynamic modification. If you need to enable it for TiDB Cloud Dedicated Tier clusters, contact [TiDB Cloud Support](/tidb-cloud/tidb-cloud-support.md). @@ -144,17 +158,25 @@ If there are too many requests that result in insufficient resources for the res ## Monitoring metrics and charts + + +TiDB regularly collects runtime information about resource control and provides visual charts of the metrics in Grafana's **TiDB** > **Resource Control** dashboard. The metrics are detailed in the **Resource Control** section of [TiDB Important Monitoring Metrics](/grafana-tidb-dashboard.md). + +TiKV also records the request QPS from different resource groups. For more details, see [TiKV Monitoring Metrics Detail](/grafana-tikv-dashboard.md#gRPC). + + + > **Note:** > > This section is only applicable to on-premises TiDB. Currently, TiDB Cloud does not provide resource control metrics. - +TiDB regularly collects runtime information about resource control and provides visual charts of the metrics in Grafana's **TiDB** > **Resource Control** dashboard. -TiDB regularly collects runtime information about resource control and provides visual charts of the metrics in Grafana's **TiDB** > **Resource Control** dashboard. The metrics are detailed in the **Resource Control** section of [TiDB Important Monitoring Metrics](/grafana-tidb-dashboard.md). +TiKV also records the request QPS from different resource groups in Grafana's **TiKV** dashboard. -TiKV also records the request QPS from different resource groups. For more details, see [TiKV Monitoring Metrics Detail](/grafana-tikv-dashboard.md#gRPC). + ## Tool compatibility From 0d85e114cf98a0b19a3b9217cbf9f4de281eb54d Mon Sep 17 00:00:00 2001 From: xixirangrang <35301108+hfxsd@users.noreply.github.com> Date: Fri, 17 Feb 2023 13:52:13 +0800 Subject: [PATCH 63/63] Update tidb-resource-control.md --- tidb-resource-control.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tidb-resource-control.md b/tidb-resource-control.md index 327977c58fc52..fb3af5fb7f6fa 100644 --- a/tidb-resource-control.md +++ b/tidb-resource-control.md @@ -68,7 +68,7 @@ Based on the above table, assuming that the TiKV time consumed by a resource gro The resource control feature introduces two new global variables. -* TiDB: you can use the [`tidb_enable_resource_control`](/system-variables.md#tidb-tidb_enable_resource_control-new-in-v660) system variable to control whether to enable flow control for resource groups. +* TiDB: you can use the [`tidb_enable_resource_control`](/system-variables.md#tidb_enable_resource_control-new-in-v660) system variable to control whether to enable flow control for resource groups. @@ -162,7 +162,7 @@ If there are too many requests that result in insufficient resources for the res TiDB regularly collects runtime information about resource control and provides visual charts of the metrics in Grafana's **TiDB** > **Resource Control** dashboard. The metrics are detailed in the **Resource Control** section of [TiDB Important Monitoring Metrics](/grafana-tidb-dashboard.md). -TiKV also records the request QPS from different resource groups. For more details, see [TiKV Monitoring Metrics Detail](/grafana-tikv-dashboard.md#gRPC). +TiKV also records the request QPS from different resource groups. For more details, see [TiKV Monitoring Metrics Detail](/grafana-tikv-dashboard.md#grpc).