Reputation: 1647
Could someone provide more details or examples about how works this load balance algorithm?
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.
Upvotes: 2
Views: 1062
Reputation: 17791
The LoadBalancerSettings.ConsistentHashLB
flag is for an Envoy configuration, and there's more detail in 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.
It's an hash algorithm that decreases the impact of servers being added and removed from Envoy's balancing pool (e.g. the servers behind a VirtualService).
Without such an algorithm, adding a single server to the pool 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.
Back to Istio - Envoy's docs again note:
A consistent hashing load balancer is only effective when protocol routing is used that specifies a value to hash on.
which means - specify a header to generate the hash from. From 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.
Upvotes: 3