Welcome! Log In Create A New Profile

Advanced

Re: weight and balancing in upstream proxy

B.R. via nginx
April 13, 2017 04:12AM
That is an interesting questions as intuitively, people could think the
former behavior applies.

If I got the source code
<https://trac.nginx.org/nginx/browser/nginx/src/http/ngx_http_upstream_round_robin.c#L507>
right, and as the docs
<https://nginx.org/en/docs/http/ngx_http_upstream_module.html#upstream>
state, nginx is following a weighted round-robin
https://en.wikipedia.org/wiki/Weighted_round_robin algorithm.
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.

To me, it would use the latter of your proposals.
​Please correct me if I am wrong, so incorrect information does not
propagate too much. :o)​
---
*B. R.*

On Wed, Apr 12, 2017 at 11:50 PM, Frank Liu <gfrankliu@gmail.com> wrote:

> Hi,
>
> 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?
>
> Thanks!
> Frank
>
>
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

weight and balancing in upstream proxy

Frank Liu April 12, 2017 05:52PM

Re: weight and balancing in upstream proxy

B.R. via nginx April 13, 2017 04:12AM

Re: weight and balancing in upstream proxy

Maxim Dounin April 13, 2017 10:36AM

Re: weight and balancing in upstream proxy

Frank Liu April 13, 2017 07:10PM

Re: weight and balancing in upstream proxy

B.R. via nginx April 14, 2017 03:16AM

Re: weight and balancing in upstream proxy

Francis Daly April 13, 2017 07:50PM

Re: weight and balancing in upstream proxy

Frank Liu April 14, 2017 01:10AM

Re: weight and balancing in upstream proxy

Francis Daly April 14, 2017 03:36AM

Re: weight and balancing in upstream proxy

Aleksandar Lazic April 14, 2017 04:48AM

Re: weight and balancing in upstream proxy

Frank Liu April 14, 2017 04:04PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 149
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready