伊斯蒂奥 0.8。关于 LoadBalancerSettings.ConsistentHashLB 的详细信息

Istio 0.8. Details about LoadBalancerSettings.ConsistentHashLB

有人可以提供有关此负载平衡算法如何工作的更多详细信息或示例吗?

https://istio.io/docs/reference/config/istio.networking.v1alpha3/#LoadBalancerSettings.ConsistentHashLB

Consistent hashing (ketama hash) based load balancer for even load distribution/redistribution when the connection pool changes. This load balancing policy is applicable only for HTTP-based connections. A user specified HTTP header is used as the key with xxHash hashing.

LoadBalancerSettings.ConsistentHashLB 标志用于 Envoy 配置,Envoy's Load Balancing Docs 中有更多详细信息:

The ring/modulo hash load balancer implements consistent hashing to upstream hosts. The algorithm is based on mapping all hosts onto a circle such that the addition or removal of a host from the host set changes only affect 1/N requests. This technique is also commonly known as “ketama” hashing.

这是一种哈希算法,可以减少在 Envoy 的平衡池中添加和删除服务器的影响(例如 VirtualService 后面的服务器)。

没有这样的算法,将单个服务器添加到池中 causes hashes to map to different servers:

We wrote ketama to replace how our memcached clients mapped keys to servers...whenever we added or removed servers from the pool, everything hashed to different servers, which effectively wiped the entire cache.


返回 Istio - Envoy 的文档再次注意:

A consistent hashing load balancer is only effective when protocol routing is used that specifies a value to hash on.

这意味着 - 指定一个 header 来生成散列。来自 Istio docs:

httpHeader | string | REQUIRED. The name of the HTTP request header that will be used to obtain the hash key. If the request header is not present, the load balancer will use a random number as the hash, effectively making the load balancing policy random.