<p>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.</p>
<pre><code>Annotations:       nginx.ingress.kubernetes.io/load-balance: ewma
</code></pre>
<p>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.</p>
<p>but when I changed the annotation to this annotation</p>
<pre><code>nginx.ingress.kubernetes.io/upstream-hash-by: &quot;ewma&quot;
</code></pre>
<p>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?</p>

<p><em>This is a community wiki answer posted for better visibility. Feel free to expand it.</em></p>
<p><strong>Root cause:</strong></p>
<p>The nodes should receive equal requests from clients (load balancing) and at the same time saving machine resources.</p>
<p>Due to this, need to find the best solution between annotations below (based on the question):</p>
<pre class="lang-yaml prettyprint-override"><code>nginx.ingress.kubernetes.io/load-balance: ewma
</code></pre>
<p>and</p>
<pre class="lang-yaml prettyprint-override"><code>nginx.ingress.kubernetes.io/upstream-hash-by: ewma
</code></pre>
<p><strong>Solution:</strong></p>
<p>Usage of <code>nginx.ingress.kubernetes.io/load-balance: ewma</code> annotation is preferable solution for the mentioned purpose.</p>
<p>Based on the <a href="https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/configmap/#load-balance" rel="nofollow noreferrer">documents</a>: <code>load-balance</code> use the Peak EWMA method for routing. In contrast, of <code>upstream-hash-by</code>, which is load balance using consistent hashing of IP or other variables and provides connection to the same pod.</p>
<p>For more information, see this article <a href="https://flugel.it/kubernetes/kubernetes-nginx-ingress-consistent-hash-subset-load-balancer/" rel="nofollow noreferrer">Kubernetes Nginx Ingress: Consistent hash subset load balancer</a>.</p>
