Skip to content
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

Add service-middleware config for pd-ctl #19023

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
52 changes: 47 additions & 5 deletions pd-control.md
Original file line number Diff line number Diff line change
Expand Up @@ -470,13 +470,17 @@ config show cluster-version
config set flow-round-by-digit 4
```

#### `config [show | set service-middleware <option> <value>]`
#### `config [show | set service-middleware <option> [<key> <value> | <label> <qps|concurrency> <value>]]`

`service-middleware` 是 PD 中的一个配置模块,主要用于管理和控制 PD 服务的中间件功能,如审计和请求速率限制等。从 v8.5.0 起,你可以通过 `service-middleware` 控制以下 gRPC API 请求的速率和并发度:
> **注意:**
>
> 通常不建议用户对请求速率限制和并发限制进行修改,此类配置可能会引起业务报错。
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

业务报错

这是不是太严重了😂

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这一段可以放在后面一点的位置,放在前面,用户还不知道 请求速率限制和并发限制 是什么

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

还有,请求速率限制和并发限制 是 HTTP 的还是 gRPC 的,还是都不建议使用?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

都不建议

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

放在后面感觉不够警示?

Copy link
Member

@okJiang okJiang Nov 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果都不建议设置的话,可以放在

  • audit: 审计功能
  • rate-limit: 用于限制 HTTP API 请求的最大速率和最大并发
  • grpc-rate-limit: 用于限制 gRPC API 请求的最大速率和最大并发

后面,就直接说不建议设置 rate-limit/grpc-rate-limit 可以吧。这样就很明确了


- `GetRegion`:获取指定 Region 的信息
- `GetStore`:获取指定 Store 的信息
- `GetMembers`:获取 PD 集群成员的信息
`service-middleware` 是 PD 中的一个配置模块,主要用于管理和控制 PD 服务的中间件功能,如审计和请求速率限制等。从 v8.5.0 起,支持通过 pd-ctl 修改 `service-middleware` 配置, `option` 支持如下几种类型:

- audit: 审计功能
- rate-limit: HTTP API 请求速率限制功能
okJiang marked this conversation as resolved.
Show resolved Hide resolved
- grpc-rate-limit: gRPC API 请求速率限制功能

显示 `service-middleware` 的相关 config 信息:

Expand All @@ -500,6 +504,20 @@ config show service-middleware
}
```

qiancai marked this conversation as resolved.
Show resolved Hide resolved
你可以通过 `service-middleware audit` 控制审计功能:

开启审计功能

```bash
config set service-middleware audit enable-audit true
```

你可以通过 `service-middleware grpc-rate-limit` 控制以下 gRPC API 请求的速率和并发度:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果只能控制这三个的话,可以加下

Suggested change
你可以通过 `service-middleware grpc-rate-limit` 控制以下 gRPC API 请求的速率和并发度:
你可以通过 `service-middleware grpc-rate-limit` 控制以下三个 gRPC API 请求的速率和并发度:

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不是,只暴露三个

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里不写“三个”也可以,不影响理解。而且,以后要是新增或减少了支持的 API 请求个数,也避免了忘记修改这里

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
你可以通过 `service-middleware grpc-rate-limit` 控制以下 gRPC API 请求的速率和并发度
`service-middleware grpc-rate-limit` 用于控制以下 gRPC API 请求的最大速率和并发度


- `GetRegion`:获取指定 Region 的信息
- `GetStore`:获取指定 Store 的信息
- `GetMembers`:获取 PD 集群成员的信息

控制某个 gRPC API 请求的速率,以 `GetRegion` API 请求为例:
okJiang marked this conversation as resolved.
Show resolved Hide resolved

```bash
Expand Down Expand Up @@ -547,6 +565,30 @@ config set service-middleware grpc-rate-limit GetRegion qps 0
config set service-middleware grpc-rate-limit GetRegion concurrency 0
```

同理,你可以通过 `service-middleware rate-limit` 控制以下 HTTP API 请求的速率和并发度:
okJiang marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
同理,你可以通过 `service-middleware rate-limit` 控制以下 HTTP API 请求的速率和并发度
`service-middleware rate-limit` 用于控制以下 HTTP API 请求的最大速率和并发度


- `GetRegion`:获取指定 Region 的信息
- `GetStore`:获取指定 Store 的信息

控制某个 HTTP API 请求的速率,以 `GetRegion` API 请求为例:

```bash
config set service-middleware rate-limit GetRegion qps 100
```

控制某个 HTTP API 请求的并发度,以 `GetRegion` API 请求为例:

```bash
config set service-middleware rate-limit GetRegion concurrency 10
```

重置上述设置:

```bash
config set service-middleware rate-limit GetRegion qps 0
config set service-middleware rate-limit GetRegion concurrency 0
```

### `config placement-rules [disable | enable | load | save | show | rule-group]`

关于 `config placement-rules` 的具体用法,参考 [Placement Rules 使用文档](/configure-placement-rules.md#配置规则操作步骤)。
Expand Down