<div dir="ltr"><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">That is an interesting questions as intuitively, people could think the former behavior applies.<br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)"><br>If I got the <a href="https://trac.nginx.org/nginx/browser/nginx/src/http/ngx_http_upstream_round_robin.c#L507">source code</a> right, and as the <a href="https://nginx.org/en/docs/http/ngx_http_upstream_module.html#upstream">docs</a> state, nginx is following a <a href="https://en.wikipedia.org/wiki/Weighted_round_robin">weighted round-robin</a> algorithm.<br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">It thus means it will go over the same list of servers everytime a peer needs to be chosen (ie for every request), and pick the first not having depleted its weight allocation.<br><br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">To me, it would use the latter of your proposals.<br></div><div class="gmail_extra"><div style="font-size:small;color:rgb(51,51,153)" class="gmail_default">​Please correct me if I am wrong, so incorrect information does not propagate too much. :o)​</div><div><div class="gmail_signature" data-smartmail="gmail_signature"><font size="1"><span style="color:rgb(102,102,102)">---<br></span><b><span style="color:rgb(102,102,102)">B. R.</span></b><span style="color:rgb(102,102,102)"></span></font></div></div>
<br><div class="gmail_quote">On Wed, Apr 12, 2017 at 11:50 PM, Frank Liu <span dir="ltr"><<a href="mailto:gfrankliu@gmail.com" target="_blank">gfrankliu@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div>How does nginx balances traffic to upstream with different weight? If I have 3 servers in upstream, with weight 1, 2, 4, assuming all are healthy, will nginx send traffic to server 1, 2, 3, 2, 3, 3, 3 or 1, 2, 2, 3, 3, 3, 3? If I have two servers with both weight 50, will nginx will 50 requests to server 1, and then 50 to server 2, or will it calculate the ration to be 1:1 and send one after another?</div><div><br></div><div>Thanks!</div><span class="HOEnZb"><font color="#888888"><div>Frank</div><div><br></div></font></span></div>
<br>______________________________<wbr>_________________<br>
nginx mailing list<br>
<a href="mailto:nginx@nginx.org">nginx@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx" rel="noreferrer" target="_blank">http://mailman.nginx.org/<wbr>mailman/listinfo/nginx</a><br></blockquote></div><br></div></div>