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

Merged
merged 12 commits into from
Dec 2, 2024
77 changes: 77 additions & 0 deletions pd-control.md
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,83 @@ config show cluster-version
config set flow-round-by-digit 4
```

#### `config [show | set service-middleware <option> <value>]`
okJiang marked this conversation as resolved.
Show resolved Hide resolved

`service-middleware` 是 PD 中的一个配置模块,主要用于管理和控制 PD 服务的中间件功能,如审计和请求速率限制等。从 v8.5.0 起,你可以通过 `service-middleware` 控制以下 gRPC API 请求的速率和并发度:

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

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

```bash
config show service-middleware
```

```bash
{
"audit": {
"enable-audit": "true"
},
"rate-limit": {
Copy link
Contributor

@niubell niubell Nov 20, 2024

Choose a reason for hiding this comment

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

@rleungx 上面@okJiang 说的有道理,我们在执行 command show 的时候能不能把 audit、rate-limiter 都隐藏掉呢?否则容易误用,既:文档里不暴露,命令行里(或者server 侧直接禁用掉、不返回)也隐藏掉

"enable-rate-limit": "true",
"limiter-config": {}
},
"grpc-rate-limit": {
"enable-grpc-rate-limit": "true",
"grpc-limiter-config": {}
}
}
```

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

```bash
config set service-middleware grpc-rate-limit GetRegion qps 100
qiancai marked this conversation as resolved.
Show resolved Hide resolved
```

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

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

查看修改后的配置:

```bash
config show service-middleware
```

```bash
{
"audit": {
"enable-audit": "true"
},
"rate-limit": {
"enable-rate-limit": "true",
"limiter-config": {}
},
"grpc-rate-limit": {
"enable-grpc-rate-limit": "true",
"grpc-limiter-config": {
"GetRegion": {
"QPS": 100,
"QPSBurst": 100,
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 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.

那感觉就在注释里加上,仅作展示就行了

"ConcurrencyLimit": 10
}
}
}
}
```

重置上述设置:

```bash
config set service-middleware grpc-rate-limit GetRegion qps 0
config set service-middleware grpc-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