Skip to content

Commit

Permalink
docs: the default selector changed (#1282)
Browse files Browse the repository at this point in the history
Co-authored-by: Yiran <[email protected]>
  • Loading branch information
fengjiachun and nicecui authored Nov 13, 2024
1 parent c984a1a commit cb6a91a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 20 deletions.
23 changes: 13 additions & 10 deletions docs/contributor-guide/metasrv/selector.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,33 @@ There is a specific scenario in `Metasrv` service. When a request to create a ta

## Selector Type

Currently, there are two types of `Selector` available in the `Metasrv` service: `LeasebasedSelector` and `LoadBasedSelector`.
The `Metasrv` service currently offers the following types of `Selectors`:

### LeasebasedSelector [not recommended]
### LeasebasedSelector

`LeasebasedSelector` is just a simple implementation of `Selector`, but **it is not recommended**.

It shuffles available `Datanode`s, and returns the list.
`LeasebasedSelector` randomly selects from all available (in lease) `Datanode`s, its characteristic is simplicity and fast.

### LoadBasedSelector

`LoadBasedSelector` is another implementation of the `Selector`.
The `LoadBasedSelector` load value is determined by the number of regions on each `Datanode`, fewer regions indicate lower load, and `LoadBasedSelector` prioritizes selecting low-load `Datanodes`.

It sorts available `Datanode`s according to the load, and returns a sorted list of these `Datanode`s.
### RoundRobinSelector [default]
`RoundRobinSelector` selects `Datanode`s in a round-robin fashion. It is recommended and the default option in most cases. If you're unsure which to choose, it's usually the right choice.

## Configuration

You can configure the `Selector` when starting the `Metasrv` service, with the default being `LoadBasedSelector`.
You can configure the `Selector` by its name when starting the `Metasrv` service.

- LeasebasedSelector: `lease_based` or `LeaseBased`
- LoadBasedSelector: `load_based` or `LoadBased`
- RoundRobinSelector: `round_robin` or `RoundRobin`

For example:

```shell
cargo run -- metasrv start --selector load_based
cargo run -- metasrv start --selector round_robin
```

```shell
cargo run -- metasrv start --selector lease_based
cargo run -- metasrv start --selector RoundRobin
```
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,33 @@

## Selector 类型

目前,在 `Metasrv` 中有两种类型的 `Selector` 可用:`LeasebasedSelector``LoadBasedSelector`
`Metasrv` 目前提供以下几种类型的 `Selectors`:

### LeasebasedSelector [不推荐]
### LeasebasedSelector

`LeasebasedSelector` 只是 `Selector` 的一个简单实现,但并不推荐。

它会对可用的 `Datanode`s 进行随机排序,然后返回列表。
`LeasebasedSelector` 从所有可用的(也就是在租约期间内)`Datanode` 中随机选择,其特点是简单和快速。

### LoadBasedSelector

`LoadBasedSelector` `Selector` 的另一种实现
`LoadBasedSelector` 按照负载来选择,负载值则由每个 `Datanode` 上的 region 数量决定,较少的 region 表示较低的负载,`LoadBasedSelector` 优先选择低负载的 `Datanode`

它根据负载对可用的 `Datanode`s 进行排序,然后返回一个已排序的 `Datanode` 列表。
### RoundRobinSelector [默认选项]
`RoundRobinSelector` 以轮询的方式选择 `Datanode`。在大多数情况下,这是默认的且推荐的选项。如果你不确定选择哪个,通常它就是正确的选择。

## 配置

在启动 `Metasrv` 服务时,您可以配置 `Selector`,默认值是 `LoadBasedSelector`
您可以在启动 `Metasrv` 服务时通过名称配置 `Selector`

- LeasebasedSelector: `lease_based``LeaseBased`
- LoadBasedSelector: `load_based``LoadBased`
- RoundRobinSelector: `round_robin``RoundRobin`

例如:

```shell
cargo run -- metasrv start --selector load_based
cargo run -- metasrv start --selector round_robin
```

```shell
cargo run -- metasrv start --selector lease_based
cargo run -- metasrv start --selector RoundRobin
```

0 comments on commit cb6a91a

Please sign in to comment.