Envoy 集群管理 位置加权负载均衡
来源:原创
时间:2019-11-24
作者:脚本小站
分类:云原生
组权重,基于locality划分的权重。
如果A组的健康端点比例为80%,B组的健康比例为60%,则按如下比例重新分配
A组权重 x 0.8 :B组权重 x 0.6,同样此种方法为了避免一有变动就重新分配流量所以也支持超配因子。如果乘以超配因子的结果大于1则取1,小于1则取小于1的值。则组权重 x 健康比例 x 超配因子。
A:effective_weight= 8 x min(1, (1.4 x 0.8))
启用位置加权:
cluster: - name: ... ... common_lb_config: locality_weighted_lb_config: {} # 启用位置加权负载均衡机制, 它没有可用的子参数; ... load_assignment: endpoints: locality: "{...}" lb_endpoints": [] load_balancing_weight: "{}" # 整数值, 定义当前位置或优先级的权重, 最小值为1; priority: "..."
位置加权负载均衡与区域感知负载均衡互斥,与优先级负载均衡可共存。
先选择优先级
再在优先级相同的中按位置权重来分配。
如果相同优先级乘以超配因子健康端点小于百分之百则一部分流量分配到次一级的上来。
三级调度:
优先级调度 -> 位置加权负载均衡调度 -> 同一个组内的端点之间负载均衡算法调度
区域->组->端点
示例:
admin: access_log_path: "/dev/null" address: socket_address: address: 0.0.0.0 port_value: 9901 static_resources: listeners: - address: socket_address: address: 0.0.0.0 port_value: 80 name: listener_http filter_chains: - filters: - name: envoy.http_connection_manager typed_config: "@type": type.googleapis.com/envoy.config.filter.network.http_connection_manager.v2.HttpConnectionManager codec_type: AUTO stat_prefix: ingress_http route_config: name: local_route virtual_hosts: - name: backend domains: - "*" routes: - match: prefix: "/" route: cluster: webcluster1 http_filters: - name: envoy.router clusters: - name: webcluster1 connect_timeout: 0.25s type: STRICT_DNS lb_policy: ROUND_ROBIN http2_protocol_options: {} common_lb_config: locality_weighted_lb_config: {} load_assignment: cluster_name: webcluster1 policy: overprovisioning_factor: 140 endpoints: - locality: region: cn-north-1 priority: 0 load_balancing_weight: 10 lb_endpoints: - endpoint: address: socket_address: address: colored port_value: 80 - locality: region: cn-north-2 priority: 0 load_balancing_weight: 20 lb_endpoints: - endpoint: address: socket_address: address: myservice port_value: 80 health_checks: - timeout: 5s interval: 10s unhealthy_threshold: 2 healthy_threshold: 1 http_health_check: path: /healthz expected_status: 200