Skip to content

Commit

Permalink
docs: VNSWRR limit the number of virtual peers per initialization (#1722
Browse files Browse the repository at this point in the history
)

* VNSWRR limit the number of virtual peers per initialization
* VNSWRR limit the number of virtual peers per initialization
* Describe the rules of `max_init`
  • Loading branch information
jizhuozhi authored Jan 12, 2023
1 parent bfa1967 commit cff1518
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 3 deletions.
36 changes: 34 additions & 2 deletions docs/modules/ngx_http_upstream_vnswrr_module.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,46 @@ make install
vnswrr
=======
```
Syntax: vnswrr
Syntax: vnswrr [max_init=number]
Default: none
Context: upstream
```

Enable `vnswrr` load balancing algorithm.
Enable `vnswrr` load balancing algorithm.

- max_init

The max number of virtual node per initialization, to avoid initializing too many virtual nodes in one request.

In very large clusters, setting this argument can significantly reduce the time overhead of a single request.

There is two another rules of `max_init`:
1. If `max_init` is not set or `0`, it will be adjusted to the number of peers.
2. If `max_init` is greater than total weight of peers, it will be adjusted to the total weight of peers.

```
http {
upstream backend {
# at most 3 virtual node per initialization
vnswrr max_init=3;
127.0.0.1 port=81 weight=101;
127.0.0.1 port=82 weight=102;
127.0.0.1 port=83 weight=103;
127.0.0.1 port=84 weight=104;
127.0.0.1 port=85 weight=105;
}
server {
server_name localhost;
location / {
proxy_pass http://backend;
}
}
}
```

## Performance


Expand Down
33 changes: 32 additions & 1 deletion docs/modules/ngx_http_upstream_vnswrr_module_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,45 @@ make install
vnswrr
=======
```
Syntax: vnswrr
Syntax: vnswrr [max_init=number]
Default: none
Context: upstream
```

在upstream里面启用 `vnswrr` 加权轮询算法。

- max_init

每次初始化虚拟结点的最大数量,避免再一次请求中初始化过多的虚拟节点。

在超大集群中,设置这个参数可以显著减少单次请求的开销。

关于`max_init`有两条额外的规则
1. 如果`max_init`没有设置或值为`0`,那么它将会被调整为节点数。
2. 如果`max_init`大于所有节点的权重之和,那么它将会被调整为所有节点的权重之和。

```
http {
upstream backend {
# at most 3 virtual node per initialization
vnswrr max_init=3;
127.0.0.1 port=81 weight=101;
127.0.0.1 port=82 weight=102;
127.0.0.1 port=83 weight=103;
127.0.0.1 port=84 weight=104;
127.0.0.1 port=85 weight=105;
}
server {
server_name localhost;
location / {
proxy_pass http://backend;
}
}
}
```

## 性能数据

Expand Down

0 comments on commit cff1518

Please sign in to comment.