From cc9dd2ef51712799a6af031466d562374bad03fb Mon Sep 17 00:00:00 2001 From: Ran Date: Thu, 18 Jun 2020 11:35:29 +0800 Subject: [PATCH 1/4] tutorial: add doc for store limit --- TOC.md | 1 + configure-store-limit.md | 80 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 configure-store-limit.md diff --git a/TOC.md b/TOC.md index adf39dc7a46bb..9876943116e55 100644 --- a/TOC.md +++ b/TOC.md @@ -116,6 +116,7 @@ + [PD Scheduling](/best-practices/pd-scheduling-best-practices.md) + [TiKV Performance Tuning with Massive Regions](/best-practices/massive-regions-best-practices.md) + [Use Placement Rules](/configure-placement-rules.md) + + [Use Store Limit](/configure-store-limit.md) + TiDB Ecosystem Tools + [Overview](/ecosystem-tool-user-guide.md) + [Use Cases](/ecosystem-tool-user-case.md) diff --git a/configure-store-limit.md b/configure-store-limit.md new file mode 100644 index 0000000000000..75d98bc7b7036 --- /dev/null +++ b/configure-store-limit.md @@ -0,0 +1,80 @@ +--- +title: Store Limit +summary: Learn the feature of Store Limit. +category: how-to +--- + +# Store Limit + +Store Limit is a feature of PD, introduced in TiDB 4.0. It is designed to control the scheduling speed in a finer manner for better performance in different scenarios. + +## Implementation principles + +PD performs scheduling at the unit of operator. An operator might contain several scheduling operations. For example: + +``` +"replace-down-replica {mv peer: store [2] to [3]} (kind:region,replica, region:10(4,5), createAt:2020-05-18 06:40:25.775636418 +0000 UTC m=+2168762.679540369, startAt:2020-05-18 06:40:25.775684648 +0000 UTC m=+2168762.679588599, currentStep:0, steps:[add learner peer 20 on store 3, promote learner peer 20 on store 3 to voter, remove peer on store 2])" +``` + +In this above example, the `replace-down-replica` operator contains the following specific operations: + +1. Add a learner peer with ID `20` on `store 3`. +2. Promote the learner peer with ID `20` on `store 3` to a voter. +3. Delete the peer on `store 2`. + +Store Limit achieves the store-level speed limit by maintaining a mapping from store IDs to token buckets in memory. The different operations here correspond to different token buckets. Currently, Store Limit only supports limiting the speed of two operations: adding learners/peers and deleting peers. That is, for each store, there are two types of token buckets. + +Every time an operator is generated, it checks whether there are enough tokens in the token buckets for its operations. If yes, the operator is added to the scheduling queue, and the corresponding token is taken from the token bucket. Otherwise, the operator is abandoned. Because the token bucket replenishes tokens at a fixed rate, the speed limit is thus achieved. + +Store Limit is different from other limit-related parameters in PD (such as `region-schedule-limit` and `leader-schedule-limit`) in that it mainly limits the consuming speed of operators, while other parameters limits the generating speed of operators. Before introducing the Store Limit feature, the speed limit of scheduling is mostly at the global scope. Therefore, even if the global speed is limited, it is still possible that the scheduling operations are concentrated on some stores, affecting the performance of the cluster. By limiting the speed at a finer level, Store Limit can better control the scheduling behavior. + +## Usage + +The parameters of Store Limit can be configured using `pd-ctl`. + +### View setting of the current store + +To view the limit setting of the current store, run the following commands: + +{{< copyable "shell-regular" >}} + +```bash +store limit // Show the speed limit of adding learners/peers in all stores (if a specific type is not set, this command shows the speed of adding learners/peers) +store limit region-add // Show the speed limit of adding learners/peers in all stores +store limit region-remove // Show the speed limit of deleting learners/peers in all stores +``` + +### Set limit for all stores + +To set the speed limit for all stores, run the following commands: + +{{< copyable "shell-regular" >}} + +```bash +store limit all 5 // All stores can at most add 5 learns/peers per minute (if a specific type is not set, this command sets the speed of adding learners/peers) +store limit all 5 region-add // All stores can at most add 5 learns/peers per minute +store limit all 5 region-remove // All stores can at most delete 5 learns/peers per minute +``` + +### Set limit for a single store + +To set the speed limit for a single store, run the following commands: + +{{< copyable "shell-regular" >}} + +```bash +store limit 1 5 // store 1 can at most add 5 learners/peers per minute (if a specific type is not set, this command sets the speed of adding learners/peers) +store limit 1 5 region-add // store 1 can at most add 5 learners/peers per minute +store limit 1 5 region-remove // store 1 can at most delete 5 learners/peers per minute +``` + +### Persist store limit modification + +Because the store limit is a mapping in the memory, the above modification is reset after the leader is switched or +PD is restarted. If you want to persist the modification, run the following command: + +{{< copyable "shell-regular" >}} + +```bash +config set store-balance-rate 20 // All stores can at most add 20 learners/peers or delete 20 peers per minute +``` From 653e3770c0ac0f6a6ee351e95c8be747f30d6fe4 Mon Sep 17 00:00:00 2001 From: Ran Date: Tue, 30 Jun 2020 17:28:57 +0800 Subject: [PATCH 2/4] Apply suggestions from code review Co-authored-by: Lilian Lee --- configure-store-limit.md | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/configure-store-limit.md b/configure-store-limit.md index 75d98bc7b7036..b0e09be95f12c 100644 --- a/configure-store-limit.md +++ b/configure-store-limit.md @@ -1,12 +1,12 @@ --- title: Store Limit summary: Learn the feature of Store Limit. -category: how-to +category: tutorials --- # Store Limit -Store Limit is a feature of PD, introduced in TiDB 4.0. It is designed to control the scheduling speed in a finer manner for better performance in different scenarios. +Store Limit is a feature of PD, introduced in TiDB 3.0. It is designed to control the scheduling speed in a finer manner for better performance in different scenarios. ## Implementation principles @@ -18,13 +18,13 @@ PD performs scheduling at the unit of operator. An operator might contain severa In this above example, the `replace-down-replica` operator contains the following specific operations: -1. Add a learner peer with ID `20` on `store 3`. -2. Promote the learner peer with ID `20` on `store 3` to a voter. +1. Add a learner peer with the ID `20` to `store 3`. +2. Promote the learner peer with the ID `20` on `store 3` to a voter. 3. Delete the peer on `store 2`. -Store Limit achieves the store-level speed limit by maintaining a mapping from store IDs to token buckets in memory. The different operations here correspond to different token buckets. Currently, Store Limit only supports limiting the speed of two operations: adding learners/peers and deleting peers. That is, for each store, there are two types of token buckets. +Store Limit achieves the store-level speed limit by maintaining a mapping from store IDs to token buckets in memory. The different operations here correspond to different token buckets. Currently, Store Limit only supports limiting the speed of two operations: adding learners/peers and deleting peers. That is, each store has two types of token buckets. -Every time an operator is generated, it checks whether there are enough tokens in the token buckets for its operations. If yes, the operator is added to the scheduling queue, and the corresponding token is taken from the token bucket. Otherwise, the operator is abandoned. Because the token bucket replenishes tokens at a fixed rate, the speed limit is thus achieved. +Every time an operator is generated, it checks whether enough tokens exist in the token buckets for its operations. If yes, the operator is added to the scheduling queue, and the corresponding token is taken from the token bucket. Otherwise, the operator is abandoned. Because the token bucket replenishes tokens at a fixed rate, the speed limit is thus achieved. Store Limit is different from other limit-related parameters in PD (such as `region-schedule-limit` and `leader-schedule-limit`) in that it mainly limits the consuming speed of operators, while other parameters limits the generating speed of operators. Before introducing the Store Limit feature, the speed limit of scheduling is mostly at the global scope. Therefore, even if the global speed is limited, it is still possible that the scheduling operations are concentrated on some stores, affecting the performance of the cluster. By limiting the speed at a finer level, Store Limit can better control the scheduling behavior. @@ -39,9 +39,9 @@ To view the limit setting of the current store, run the following commands: {{< copyable "shell-regular" >}} ```bash -store limit // Show the speed limit of adding learners/peers in all stores (if a specific type is not set, this command shows the speed of adding learners/peers) -store limit region-add // Show the speed limit of adding learners/peers in all stores -store limit region-remove // Show the speed limit of deleting learners/peers in all stores +store limit // Shows the speed limit of adding learners/peers in all stores (if a specific type is not set, this command shows the speed of adding learners/peers). +store limit region-add // Shows the speed limit of adding learners/peers in all stores. +store limit region-remove // Shows the speed limit of deleting learners/peers in all stores. ``` ### Set limit for all stores @@ -51,9 +51,9 @@ To set the speed limit for all stores, run the following commands: {{< copyable "shell-regular" >}} ```bash -store limit all 5 // All stores can at most add 5 learns/peers per minute (if a specific type is not set, this command sets the speed of adding learners/peers) -store limit all 5 region-add // All stores can at most add 5 learns/peers per minute -store limit all 5 region-remove // All stores can at most delete 5 learns/peers per minute +store limit all 5 // All stores can at most add 5 learns/peers per minute (if a specific type is not set, this command sets the speed of adding learners/peers). +store limit all 5 region-add // All stores can at most add 5 learns/peers per minute. +store limit all 5 region-remove // All stores can at most delete 5 learns/peers per minute. ``` ### Set limit for a single store @@ -63,9 +63,9 @@ To set the speed limit for a single store, run the following commands: {{< copyable "shell-regular" >}} ```bash -store limit 1 5 // store 1 can at most add 5 learners/peers per minute (if a specific type is not set, this command sets the speed of adding learners/peers) -store limit 1 5 region-add // store 1 can at most add 5 learners/peers per minute -store limit 1 5 region-remove // store 1 can at most delete 5 learners/peers per minute +store limit 1 5 // store 1 can at most add 5 learners/peers per minute (if a specific type is not set, this command sets the speed of adding learners/peers). +store limit 1 5 region-add // store 1 can at most add 5 learners/peers per minute. +store limit 1 5 region-remove // store 1 can at most delete 5 learners/peers per minute. ``` ### Persist store limit modification @@ -76,5 +76,5 @@ PD is restarted. If you want to persist the modification, run the following comm {{< copyable "shell-regular" >}} ```bash -config set store-balance-rate 20 // All stores can at most add 20 learners/peers or delete 20 peers per minute +config set store-balance-rate 20 // All stores can at most add 20 learners/peers or delete 20 peers per minute. ``` From 2d8c671b24b7e7437b996d252994a5a93cada96b Mon Sep 17 00:00:00 2001 From: Ran Date: Tue, 30 Jun 2020 19:58:27 +0800 Subject: [PATCH 3/4] align with https://github.com/pingcap/docs-cn/pull/3831 --- configure-store-limit.md | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/configure-store-limit.md b/configure-store-limit.md index b0e09be95f12c..acaed280ad7b0 100644 --- a/configure-store-limit.md +++ b/configure-store-limit.md @@ -39,9 +39,9 @@ To view the limit setting of the current store, run the following commands: {{< copyable "shell-regular" >}} ```bash -store limit // Shows the speed limit of adding learners/peers in all stores (if a specific type is not set, this command shows the speed of adding learners/peers). -store limit region-add // Shows the speed limit of adding learners/peers in all stores. -store limit region-remove // Shows the speed limit of deleting learners/peers in all stores. +store limit // Shows the speed limit of adding or deleting peers in all stores. +store limit add-peer // Shows the speed limit of adding peers in all stores. +store limit remove-peer // Shows the speed limit of deleting peers in all stores. ``` ### Set limit for all stores @@ -51,9 +51,9 @@ To set the speed limit for all stores, run the following commands: {{< copyable "shell-regular" >}} ```bash -store limit all 5 // All stores can at most add 5 learns/peers per minute (if a specific type is not set, this command sets the speed of adding learners/peers). -store limit all 5 region-add // All stores can at most add 5 learns/peers per minute. -store limit all 5 region-remove // All stores can at most delete 5 learns/peers per minute. +store limit all 5 // All stores can at most add or delete 5 peers per minute. +store limit all 5 add-peer // All stores can at most add 5 peers per minute. +store limit all 5 remove-peer // All stores can at most delete 5 peers per minute. ``` ### Set limit for a single store @@ -63,18 +63,7 @@ To set the speed limit for a single store, run the following commands: {{< copyable "shell-regular" >}} ```bash -store limit 1 5 // store 1 can at most add 5 learners/peers per minute (if a specific type is not set, this command sets the speed of adding learners/peers). -store limit 1 5 region-add // store 1 can at most add 5 learners/peers per minute. -store limit 1 5 region-remove // store 1 can at most delete 5 learners/peers per minute. -``` - -### Persist store limit modification - -Because the store limit is a mapping in the memory, the above modification is reset after the leader is switched or -PD is restarted. If you want to persist the modification, run the following command: - -{{< copyable "shell-regular" >}} - -```bash -config set store-balance-rate 20 // All stores can at most add 20 learners/peers or delete 20 peers per minute. +store limit 1 5 // store 1 can at most add or delete 5 peers per minute. +store limit 1 5 add-peer // store 1 can at most add 5 peers per minute. +store limit 1 5 remove-peer // store 1 can at most delete 5 peers per minute. ``` From 0ec935cae844e5cb3550ba5900b52985b4cc46c0 Mon Sep 17 00:00:00 2001 From: Ran Date: Wed, 1 Jul 2020 14:24:03 +0800 Subject: [PATCH 4/4] Apply suggestions from code review Co-authored-by: Ryan Leung --- configure-store-limit.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure-store-limit.md b/configure-store-limit.md index acaed280ad7b0..12facdd4d1fd0 100644 --- a/configure-store-limit.md +++ b/configure-store-limit.md @@ -39,7 +39,7 @@ To view the limit setting of the current store, run the following commands: {{< copyable "shell-regular" >}} ```bash -store limit // Shows the speed limit of adding or deleting peers in all stores. +store limit // Shows the speed limit of adding and deleting peers in all stores. store limit add-peer // Shows the speed limit of adding peers in all stores. store limit remove-peer // Shows the speed limit of deleting peers in all stores. ``` @@ -51,7 +51,7 @@ To set the speed limit for all stores, run the following commands: {{< copyable "shell-regular" >}} ```bash -store limit all 5 // All stores can at most add or delete 5 peers per minute. +store limit all 5 // All stores can at most add and delete 5 peers per minute. store limit all 5 add-peer // All stores can at most add 5 peers per minute. store limit all 5 remove-peer // All stores can at most delete 5 peers per minute. ``` @@ -63,7 +63,7 @@ To set the speed limit for a single store, run the following commands: {{< copyable "shell-regular" >}} ```bash -store limit 1 5 // store 1 can at most add or delete 5 peers per minute. +store limit 1 5 // store 1 can at most add and delete 5 peers per minute. store limit 1 5 add-peer // store 1 can at most add 5 peers per minute. store limit 1 5 remove-peer // store 1 can at most delete 5 peers per minute. ```