k8gb-io / k8gb

A cloud native Kubernetes Global Balancer
https://www.k8gb.io
Apache License 2.0
877 stars 93 forks source link

Investigate consistent hashing to enable creation of advanced GSLB strategies #849

Open ytsarev opened 2 years ago

ytsarev commented 2 years ago

Originally idea comes from @donovanmuller

I cannot find the dedicated issue for it, so creating a new one.

With the introduction of https://github.com/k8gb-io/coredns-crd-plugin we can more dynamically affect the dynamics DNS responses and associated traffic distribution. It creates a good opportunity to employ advanced technics for more granular load distribution, potentially utilizing consistent hashing

https://www.toptal.com/big-data/consistent-hashing https://medium.com/vimeo-engineering-blog/improving-load-balancing-with-a-new-consistent-hashing-algorithm-9f1bd75709ed https://vimeo.com/240695782

kuritka commented 2 years ago

From the discussion I had with CoreDNS, it seems that the implementation will be in our coredns-crd-plugin or an external LoadBalancer must be added (basically we simulate its functionality). They will not allow contribution as this functionality should not be there.

Just a reminder that Consistent hashing works that clients A and C will always connect to server X while clients B, D and E will always connect to server Y. Consistent hashing should ensure that if a server goes down or new is added, there will be minimum affected clients which starts connect to different server. On the other hand, consistent hashing alghoritm doesn't handle situation, where client D and E make 45% and 45% of total traffic (it will still connect them to the same server).