Skip to content

Commit fb4db58

Browse files
author
𝐘𝐨𝐬𝐞𝐛𝐲𝐭𝐞
authored
docs: update load balancing strategies to include optimal-latency option in API and configuration documentation
1 parent 3939dd6 commit fb4db58

4 files changed

Lines changed: 20 additions & 18 deletions

File tree

docs/en/api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1588,7 +1588,7 @@ Examples:
15881588
| `key` | Private key path | File path | None | Server only |
15891589
| `dns` | DNS cache duration | Time duration (e.g., `5m`, `30s`, `1h`) | `5m` | Both |
15901590
| `sni` | Server Name Indication | Hostname | `none` | Client dual-end handshake mode only |
1591-
| `lbs` | Load balancing strategy | `0`(round-robin), `1`(sticky-failover), `2`(primary-backup) | `0` | Both |
1591+
| `lbs` | Load balancing strategy | `0`(round-robin), `1`(optimal-latency), `2`(primary-backup) | `0` | Both |
15921592
| `min` | Minimum pool capacity | Integer > 0 | `64` | Client dual-end handshake mode only |
15931593
| `max` | Maximum pool capacity | Integer > 0 | `1024` | Dual-end handshake mode |
15941594
| `mode` | Runtime mode control | `0`(auto), `1`(force mode 1), `2`(force mode 2) | `0` | Both |

docs/en/configuration.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -699,10 +699,11 @@ NodePass provides three load balancing strategies controlled by the `lbs` parame
699699
- **Failover**: When a connection to an address fails, immediately tries the next address to ensure service availability
700700
- **Automatic Recovery**: Failed addresses are retried in subsequent rotation cycles and automatically resume receiving traffic after recovery
701701

702-
**Strategy 1 (Sticky-Failover):**
703-
- **Connection Stickiness**: Continues using the current target address as long as connections succeed
704-
- **Failover Only**: Switches to the next address only when connection failures occur
705-
- **Persistent Target**: Once switched to a new address, all subsequent connections use that address until it fails
702+
**Strategy 1 (Optimal-Latency):**
703+
- **Intelligent Routing**: Periodically probes targets and automatically selects the one with the lowest latency for connections.
704+
- **Sticky Selection**: Once the optimal target is chosen, subsequent connections within the cycle preferentially use that target.
705+
- **Automatic Filtering**: Unhealthy targets are automatically excluded from routing and re-evaluated only after recovery.
706+
- **Failover**: If the optimal target fails, other targets are tried in order to ensure successful connections.
706707

707708
**Strategy 2 (Primary-Backup):**
708709
- **Priority-Based**: Always attempts to connect to the first address (primary); only uses backups when primary fails
@@ -716,7 +717,7 @@ Example configurations:
716717
# Round-robin (lbs=0, cycles through targets on each connection)
717718
nodepass "server://0.0.0.0:10101/backend1:8080,backend2:8080,backend3:8080?lbs=0"
718719

719-
# Sticky failover (lbs=1, stays on current target until failure)
720+
# Optimal-latency (lbs=1, automatically routes to fastest target)
720721
nodepass "server://0.0.0.0:10101/backend1:8080,backend2:8080,backend3:8080?lbs=1"
721722

722723
# Primary-backup (lbs=2, primary priority and scheduled fallback)
@@ -729,7 +730,7 @@ nodepass "server://0.0.0.0:10101/main.com:443,spare1.com:443,spare2.com:443?lbs=
729730

730731
Choose the appropriate strategy based on your needs:
731732
- **Use lbs=0** for even load distribution across all backends
732-
- **Use lbs=1** for session persistence and reduced backend switching
733+
- **Use lbs=1** for intelligent routing to the lowest latency target
733734
- **Use lbs=2** for primary-backup scenarios with automatic failback
734735

735736
### Use Cases

docs/zh/api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1588,7 +1588,7 @@ client://<server_host>:<server_port>/<local_host>:<local_port>?<parameters>
15881588
| `key` | 私钥路径 | 文件路径 || 仅服务端 |
15891589
| `dns` | DNS缓存时间 | 时间长度 (如 `10m`, `30s`, `1h`) | `5m` | 两者 |
15901590
| `sni` | 主机名指示 | 主机名 | `none` | 仅客户端双端握手模式 |
1591-
| `lbs` | 负载均衡策略 | `0`(轮询), `1`(粘性), `2`(主备) | `0` | 两者 |
1591+
| `lbs` | 负载均衡策略 | `0`(轮询转移), `1`(最优延迟), `2`(主备回落) | `0` | 两者 |
15921592
| `min` | 最小连接池容量 | 整数 > 0 | `64` | 仅客户端双端握手模式 |
15931593
| `max` | 最大连接池容量 | 整数 > 0 | `1024` | 双端握手模式 |
15941594
| `mode` | 运行模式控制 | `0`(自动), `1`(强制模式1), `2`(强制模式2) | `0` | 两者 |

docs/zh/configuration.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -694,17 +694,18 @@ nodepass "client://127.0.0.1:1080/app1.local:8080,app2.local:8080?mode=1"
694694

695695
NodePass提供三种负载均衡策略,通过 `lbs` 参数控制:
696696

697-
**策略0(轮询故障转移):**
697+
**策略0(轮询转移):**
698698
- **负载均衡**:每次成功建立连接后,自动切换到下一个目标地址,实现流量均匀分布
699699
- **故障转移**:当某个地址连接失败时,立即尝试下一个地址,确保服务高可用
700700
- **自动恢复**:失败的地址会在轮询周期中重新尝试,故障恢复后自动接入流量
701701

702-
**策略1(粘性故障转移):**
703-
- **连接粘性**:只要连接成功,就持续使用当前目标地址
704-
- **失败切换**:只有当连接失败时才切换到下一个地址
705-
- **目标持久**:切换到新地址后,后续所有连接都使用该地址直到失败
702+
**策略1(最优延迟):**
703+
- **智能路由**:周期性探测,自动选择延迟最低的目标进行连接
704+
- **粘性选择**:最优目标选择后,周期内后续连接优先使用该目标
705+
- **自动筛选**:失效目标自动排除,不参与路由,直至恢复后再评估
706+
- **故障转移**:最优目标失败时按顺序尝试其他目标,确保连接成功
706707

707-
**策略2(主备故障转移):**
708+
**策略2(主备回落):**
708709
- **主备优先**:首个目标地址主用,后续目标地址备用,按顺序优先级递减
709710
- **故障转移**:主目标地址失败时按顺序尝试备用地址,成功后保持粘性
710711
- **定时回落**:每隔固定时间自动尝试回落到主用目标地址
@@ -713,13 +714,13 @@ NodePass提供三种负载均衡策略,通过 `lbs` 参数控制:
713714
配置示例:
714715

715716
```bash
716-
# 轮询故障转移(lbs=0,每次连接切换目标)
717+
# 轮询转移(lbs=0,每次连接切换目标)
717718
nodepass "server://0.0.0.0:10101/backend1:8080,backend2:8080,backend3:8080?lbs=0"
718719

719-
# 粘性故障转移(lbs=1,成功时保持当前目标
720+
# 最优延迟(lbs=1,自动路由到最快目标
720721
nodepass "server://0.0.0.0:10101/backend1:8080,backend2:8080,backend3:8080?lbs=1"
721722

722-
# 主备故障转移(lbs=2,首目标优先且定时回落)
723+
# 主备回落(lbs=2,首目标优先且定时回落)
723724
nodepass "server://0.0.0.0:10101/primary:8080,backup1:8080,backup2:8080?lbs=2"
724725

725726
# 自定义回落间隔为2分钟
@@ -729,7 +730,7 @@ nodepass "server://0.0.0.0:10101/main.com:443,spare1.com:443,spare2.com:443?lbs=
729730

730731
根据实际需求选择合适的策略:
731732
- **使用 lbs=0** 实现所有后端的均匀负载分布
732-
- **使用 lbs=1** 减少后端切换,保持会话粘性
733+
- **使用 lbs=1** 智能路由到延迟最低目标地址
733734
- **使用 lbs=2** 主备模式,故障消除自动回切
734735

735736
### 使用场景

0 commit comments

Comments
 (0)