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

docs: the default selector changed #1282

Merged
merged 6 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
```
Loading