upsync_lb
`upsync_lb` 指令用于配置从 Consul 或 etcd 等后端服务注册表同步数据的 upstream 服务器的负载均衡行为。
NGINX module for syncing upstreams from consul or etcd
·
upstream
语法upsync_lb number;
默认值none
上下文upstream
参数1
说明
upsync_lb 指令在 upstream 块中使用,用于指定在从外部服务注册表(如 Consul 或 etcd)同步 upstream 服务器配置时应如何处理负载均衡。启用后,它指示 NGINX 服务器动态维护更新的后端服务器属性,而无需重新加载服务器配置。这包括诸如 server weight and maximum fail settings 之类的属性。它有助于在运行时简化流量管理,根据实时服务可用性和性能指标进行自动调整。
该指令接受单个参数,该参数应指定预期的负载均衡策略或模式。当服务状态频繁变化时,其集成对于保持 upstream 配置同步的最佳状态至关重要。通过使用 upsync_lb,管理员可以确保从应用流量的角度,在扩展服务或在健康检查后服务器状态改变时,不会发生突发的性能瓶颈或停机。
配置示例
upstream test {
upsync 127.0.0.1:8500/v1/kv/upstreams/test/ upsync_timeout=6m upsync_interval=500ms upsync_type=consul strong_dependency=off;
upsync_lb 1;
upsync_dump_path /usr/local/nginx/conf/servers/servers_test.conf;
include /usr/local/nginx/conf/servers/servers_test.conf;
}⚠
确保所选的负载均衡方法与您的后端服务和流量模式兼容。
⚠
参数值不正确可能导致意外的服务停机或性能下降。
⚠
在进行 upsync 配置时,并非所有负载均衡策略都可能受支持。请根据模块文档进行核实。