Kubernetes Service : IPVS load balancing algorithm

4/16/2019

As discovered here, there is new kind of kube service that are IPVS and have many algorithm for load balancing.

The only problem is I didn't find where those algorithm are specified.

My understanding:

  1. rr: round-robin -> call backend pod one after another in a loop
  2. lc: least connection -> group all pod with lowest number of connection, and send message to it. Which kind of connection ? only the ones from this service ?
  3. dh: destination hashing -> ?something based on url?
  4. sh: source hashing -> ?something based on url?
  5. sed: shortest expected delay -> either the backend with less ping or some logic on the time a backend took to respond in the past
  6. nq: never queue -> same as least connection ? but refusing messages at some points ?

If anyone has the documentation link (not provided in the official page and still saying IPVS is beta whereas it is stable sinc 1.11) or the real algorithm behind all of them, please help.

I tried : Google search with the terms + lookup in the official documentation.

-- charlescFR
google-kubernetes-engine
kubectl
kubernetes

1 Answer

4/16/2019

They are defined in the code https://github.com/kubernetes/kubernetes/blob/master/pkg/proxy/apis/config/types.go#L193

  • rr round robin : distributes jobs equally amongst the available real servers
  • lc least connection : assigns more jobs to real servers with fewer active jobs
  • sh source hashing : assigns jobs to servers through looking up a statically assigned hash table by their source IP addresses
  • dh destination hashing : assigns jobs to servers through looking up a statically assigned hash table by their destination IP addresses
  • sed shortest expected delay : assigns an incoming job to the server with the shortest expected delay. The expected delay that the job will experience is (Ci + 1) / Ui if sent to the ith server, in which Ci is the number of jobs on the ith server and Ui is the fixed service rate (weight) of the ith server.
  • nq never queue : assigns an incoming job to an idle server if there is, instead of waiting for a fast one; if all the servers are busy, it adopts the ShortestExpectedDelay policy to assign the job.

All those come from IPVS official documentation : http://www.linuxvirtualserver.org/docs/scheduling.html

Regards

-- charlescFR
Source: StackOverflow