How does nginx weighting work?

Maxim Dounin mdounin at mdounin.ru
Fri Oct 2 14:53:21 UTC 2015


Hello!

On Fri, Oct 02, 2015 at 10:22:14AM -0400, highclass99 wrote:

> upstream myCloud{
>   server 10.0.0.1 weight=10;
>   server 10.0.0.2 weight=20;
> } 
> 
> For 30 sequential requests,
> will it work like
> A.
> 10.0.0.1 10.0.0.2 10.0.0.2 -> 10.0.0.1 10.0.0.2 10.0.0.2 -> ... total 10
> times repeat
> 
> or will it work like
> B.
> 10.0.0.1 ... 10 times repeat -> 10.0.0.2... 20 times repeat
> 
> Because if it works like A, it would be helpful to use large numbers to fine
> tune weighting.
> But, if it works like B, it would be harmful to use large numbers to fine
> tune weighting.

It uses something more like A, though slightly more sophisticated.  
Details of the algorithm currently used can be found here:

http://hg.nginx.org/nginx/rev/c90801720a0c

-- 
Maxim Dounin
http://nginx.org/



More information about the nginx mailing list