-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add store limit guide #3353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Add store limit guide #3353
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
fec128e
resources: update the Figma link (#3230)
CaitinChen 709bedd
add store limit guide
rleungx 994f993
Apply suggestions from code review
TomShawn 27f620c
add store limit guide
rleungx dd2e2a2
Apply suggestions from code review
TomShawn 834329c
address the comment
rleungx 35961eb
Merge branch 'store-limit' of https://github.com/rleungx/docs-cn into…
TomShawn 9779953
Update configure-store-limit.md
TomShawn 4913cce
address the comment
rleungx 1e87914
Merge remote-tracking branch 'origin/store-limit' into store-limit
rleungx dc59bed
Update configure-store-limit.md
rleungx a69ef3e
Update configure-store-limit.md
TomShawn 2947015
Merge branch 'docs-special-week' into store-limit
sre-bot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| --- | ||
| title: Store Limit | ||
| summary: 介绍 Store Limit 功能。 | ||
| category: how-to | ||
| --- | ||
|
|
||
| # Store Limit | ||
|
|
||
| Store Limit 是 PD 在 3.0 版本引入的特性,旨在能够更加细粒度地控制调度的速度,针对不同调度场景进行调优。 | ||
|
|
||
| ## 实现原理 | ||
|
|
||
| PD 的调度是以 operator 为单位执行的。一个 operator 可能包含多个调度操作。示例如下; | ||
|
|
||
| ``` | ||
| "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])" | ||
| ``` | ||
|
|
||
| 以上示例中,`replace-down-replica` 这个 operator 具体包含以下操作: | ||
|
|
||
| 1. 在 `store 3` 上添加一个 learner peer,ID 为 `20`。 | ||
| 2. 将 `store 3` 上 ID 为 `20` 的 learner peer 提升为 voter。 | ||
| 3. 删除 `store 2` 上的 peer。 | ||
|
|
||
| Store Limit 是通过在内存中维护了一个 store ID 到令牌桶的映射,来实现 store 级别的限速。这里不同的操作对应不同的令牌桶,目前仅支持限制添加 learner/peer 和删除 peer 两种操作的速度,即对应于每个 store 存在两种类型的令牌桶。 | ||
|
|
||
| 每次 operator 产生后会检查所包含的操作对应的令牌桶中是否有足够的 token。如果 token 充足才会将该 operator 加入到调度的队列中,同时从令牌桶中拿走对应的 token,否则该 operator 被丢弃。令牌桶会按照固定的速率补充 token,从而实现限速的目的。 | ||
|
|
||
| Store Limit 与 PD 其他 limit 相关的参数(如 `region-schedule-limit`,`leader-schedule-limit` 等)不同的是,Store Limit 限制的主要是 operator 的消费速度,而其他的 limit 主要是限制 operator 的产生速度。引入 Store Limit 特性之前,调度的限速主要是全局的,所以即使限制了全局的速度,但还是有可能存在调度都集中在部分 store 上面,因而影响集群的性能。而 Store Limit 通过将限速的粒度进一步细化,可以更好的控制调度的行为。 | ||
|
|
||
| ## 使用方法 | ||
|
|
||
| Store Limit 相关的参数可以通过 `pd-ctl` 进行设置。 | ||
|
|
||
| ### 查看当前 store 的 limit 设置 | ||
|
|
||
| 查看当前 store 的 limit 示例如下: | ||
|
|
||
| {{< copyable "shell-regular" >}} | ||
|
|
||
| ```bash | ||
| store limit // 显示所有 store 添加 learner/peer 的速度上限 (如不设置具体类型,则显示的是添加 learner/peer 的速度)。 | ||
| store limit region-add // 显示所有 store 添加 learner/peer 的速度上限。 | ||
| store limit region-remove // 显示所有 store 删除 peer 的速度上限。 | ||
| ``` | ||
|
|
||
| ### 设置全部 store 的 limit | ||
|
|
||
| 设置全部 store 的 limit 示例如下: | ||
|
|
||
| {{< copyable "shell-regular" >}} | ||
|
|
||
| ```bash | ||
| store limit all 5 // 设置所有 store 添加 learner/peer 的速度上限为每分钟 5 个(如不设置具体类型,则默认设置的是添加 learner/peer 的速度)。 | ||
| store limit all 5 region-add // 设置所有 store 添加 learner/peer 的速度上限为每分钟 5 个。 | ||
| store limit all 5 region-remove // 设置所有 store 删除 peer 的速度上限为每分钟 5 个。 | ||
| ``` | ||
|
|
||
| ### 设置单个 store 的 limit | ||
|
|
||
| 设置单个 store 的 limit 示例如下: | ||
|
|
||
| {{< copyable "shell-regular" >}} | ||
|
|
||
| ```bash | ||
| store limit 1 5 // 设置 store 1 添加 learner/peer 的速度上限为每分钟 5 个(如不设置具体类型,则默认设置的是添加 learner/peer 的速度)。 | ||
| store limit 1 5 region-add // 设置 store 1 添加 learner/peer 的速度上限为每分钟 5 个。 | ||
| store limit 1 5 region-remove // 设置 store 1 删除 peer 的速度上限为每分钟 5 个。 | ||
| ``` | ||
|
|
||
| ### 持久化 store limit 修改 | ||
|
|
||
| 由于 store limit 是一个内存中的映射关系,所以上述的修改在切换 leader 或者 PD 重启后会被重置。如果同时想要持久化修改,可以同时使用下面的方法进行设置: | ||
|
|
||
| {{< copyable "shell-regular" >}} | ||
|
|
||
| ```bash | ||
| config set store-balance-rate 20 // 将所有 store 添加 learner/peer 和删除 peer 的速度上限为每分钟 20 个 | ||
| ``` | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.