1

I have one service with 10 pods inside of my cluster and it sends multiple requests to the master node for more than an hour. I put an annotation in my ingress resource and modified it with some annotation, the first annotation I used is only to change the load balancer method to ewma load balancing.

Annotations:       nginx.ingress.kubernetes.io/load-balance: ewma

During the time when the client requested the service from the master node, it received the request perfectly, which means the client received different responses from different pods and from different agent nodes inside of the cluster.

but when I changed the annotation to this annotation

nginx.ingress.kubernetes.io/upstream-hash-by: "ewma"

the client received the same answer every time from the same pod and from the same node, even I send requests for the service 5 times in a second for more than 30 minutes. are they implemented correctly? and why are they different?

newcomers
  • 161
  • 1
  • 12
  • Can you improve your question? "client received the request", "client received the same answer" - are you sure it's a client in both cases? "but when I do change to this annotation" - it's not the same annotation. They are different. Please provide all annotations for the first case with the expected result, then the same for the second case. Now it is hard to understand the problem you are faced with. – Andrew Skorkin Mar 28 '22 at 15:59
  • please check my update – newcomers Mar 30 '22 at 00:33
  • Hi @rthamrin Based on the [documents](https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/configmap/#load-balance): `load-balance` use the Peak EWMA method for routing and `upstream-hash-by` is load balance using consistent hashing of IP or other variables. Thus, this is an expected behavior. You can look at this article [Kubernetes Nginx Ingress: Consistent hash subset load balancer](https://flugel.it/kubernetes/kubernetes-nginx-ingress-consistent-hash-subset-load-balancer/) to get more information. Again, please provide your expected result. – Andrew Skorkin Mar 31 '22 at 12:07
  • Thanks man! I will read it. My expected results are the nodes receiving equal requests from the clients ( load balance) at the same time saving the resources of the machine. – newcomers Mar 31 '22 at 12:43
  • Okay, and for this purpose, I think only the first annotation `nginx.ingress.kubernetes.io/load-balance: ewma` will be applicable for you. – Andrew Skorkin Apr 01 '22 at 08:52
  • Hi @rthamrin Any updates from your side? – Andrew Skorkin Apr 06 '22 at 15:07
  • I use peak ewma with this annotation ```nginx.ingress.kubernetes.io/load-balance: ewma``` instead. – newcomers Apr 08 '22 at 01:37

1 Answers1

1

This is a community wiki answer posted for better visibility. Feel free to expand it.

Root cause:

The nodes should receive equal requests from clients (load balancing) and at the same time saving machine resources.

Due to this, need to find the best solution between annotations below (based on the question):

nginx.ingress.kubernetes.io/load-balance: ewma

and

nginx.ingress.kubernetes.io/upstream-hash-by: ewma

Solution:

Usage of nginx.ingress.kubernetes.io/load-balance: ewma annotation is preferable solution for the mentioned purpose.

Based on the documents: load-balance use the Peak EWMA method for routing. In contrast, of upstream-hash-by, which is load balance using consistent hashing of IP or other variables and provides connection to the same pod.

For more information, see this article Kubernetes Nginx Ingress: Consistent hash subset load balancer.

Andrew Skorkin
  • 1,147
  • 3
  • 11