负载均衡重构: 子网感知选择 + 节点健康监控 + 节点注册上报API

- 新增 subnet-aware 负载策略: 根据客户端IP匹配最近/16子网节点
- 节点注册端点 (POST /api/nodes/register): 边缘节点自动注册
- 节点心跳端点 (POST /api/nodes/heartbeat): 上报CPU/RAM/带宽/连接数
- 健康汇总 (GET /api/nodes/health): 服务端汇总所有节点状态
- 配置节点新增subnet/is_origin字段
- 前端NodeManager: 实时健康状态/CPU/RAM进度条/带宽/连接数
- X-Forwarded-For/X-Real-IP透传支持客户端IP
This commit is contained in:
admin committed 2026-08-10 14:45:28 +08:00
1 parent 5f19fc6aa5
commit 980b91f41f
7 files changed
+319 -87

No files matched your search

+12 -5
View File
@@ -12,13 +12,20 @@ class Settings(BaseSettings):
media_origin_hls_port: int = 8888
edge_nodes: list[dict] = [
{"id": "edge-1", "name": "Edge Node 1", "host": "127.0.0.1",
"hls_port": 8889, "api_port": 9998, "weight": 100, "enabled": True},
{"id": "edge-2", "name": "Edge Node 2", "host": "127.0.0.1",
"hls_port": 8890, "api_port": 9999, "weight": 50, "enabled": True},
{
"id": "default",
"name": "Origin (Default)",
"host": "127.0.0.1",
"hls_port": 8888,
"api_port": 9997,
"weight": 100,
"enabled": True,
"subnet": "0.0.0.0/0",
"is_origin": True,
},
]
load_balance_strategy: Literal["round-robin", "weighted", "least-conn"] = "weighted"
load_balance_strategy: Literal["round-robin", "weighted", "least-conn", "subnet"] = "subnet"
qualities: list[dict] = [
{"label": "1080p", "width": 1920, "height": 1080, "bitrate": "5000k"},