Welcome! Log In Create A New Profile

Advanced

Re: Selection of server in upstream directive using hash

October 11, 2017 05:48AM
Well I'd expect that when using "server chat" as per the docs:

"A domain name that resolves to several IP addresses defines multiple
servers at once."

the hash wouldn't be consistent on choosing the name, but on the server
list, because it defines multiple servers.

2017-10-09 12:23 GMT+02:00 Roman Arutyunyan <arut@nginx.com>:
>
> Hi Ruben,
>
> On Mon, Oct 09, 2017 at 11:51:54AM +0200, Ruben wrote:
> > First of all thanks for your reply. But what happens if I have for
example
> > a hostname: test, which resolves to a randomized list of multiple ip's.
> > Such that when I do:
> >
> > dig test
> > 10.0.0.8
> > 10.0.0.9
> > 10.0.0.10
> >
> > and a few moments later
> >
> > dig test
> > 10.0.0.10
> > 10.0.0.8
> > 10.0.0.9
> >
> > Is it then still consistent on the ip's or is the consistency just on
the
> > name "test" in this case?
>
> The consistency is only about choosing the name "test". Once the name is
> chosen (consistently), its ips are balanced by the round-robin balancer.
> With this approach you can change ips of your server or add new addresses
to
> it and everything will keep working as before. However, you cannot stick
> to a particular ip address of a server.
>
> > From the docs I read that it resolves the hostname and injects the ip's
as
> > server when multiple ip's are returned. But it's not completely clear on
> > which the hash is acting.
> >
> > I am asking this, because docker constantly returns a randomized fixed
list
> > of ip's (for dns load balancing). But I always want to route a user,
> > targetting for some url, to the same container.
>
> In the commercial version of nginx we have the sticky module, which can
be used
> to solve your issue:
>
> http://nginx.org/en/docs/http/ngx_http_upstream_module.html#sticky
>
> > 2017-10-09 11:25 GMT+02:00 Roman Arutyunyan <arut@nginx.com>:
> >
> > > Hi Ruben,
> > >
> > > On Mon, Oct 09, 2017 at 09:33:55AM +0200, Ruben wrote:
> > > > I was wondering what the selection algorithm is for choosing a
server in
> > > > the upstream directive using hash. Is the selection based on the ip
of
> > > the
> > > > server or is it based on the position of the list.
> > > >
> > > > So if I have for example the following configuration:
> > > >
> > > > upstream test {
> > > > hash $arg_test;
> > > > server 10.0.0.10;
> > > > server 10.0.0.9;
> > > > server 10.0.0.8;
> > > > }
> > > >
> > > > or (ip's in different order)
> > > >
> > > > upstream chat {
> > > > hash $arg_test;
> > > > server 10.0.0.8;
> > > > server 10.0.0.9;
> > > > server 10.0.0.10;
> > > > }
> > > >
> > > > If someone is targeting an url with ?test=1, is it in both configs
> > > directed
> > > > to the same ip or not. So is the selection based on the ip or based
omn
> > > the
> > > > position in the list.
> > >
> > > The regular (non-consistent) hash balancer selects a server based on
the
> > > position in the list. However, the consistent hash balancer
> > > (hash $arg_test consistent) makes a selection based on the server
name/ip
> > > specified in the "server" directive.
> > >
> > > --
> > > Roman Arutyunyan
> > > _______________________________________________
> > > 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
>
>
> --
> Roman Arutyunyan
> _______________________________________________
> 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

Selection of server in upstream directive using hash

rsdrsd October 09, 2017 03:36AM

Re: Selection of server in upstream directive using hash

Roman Arutyunyan October 09, 2017 05:26AM

Re: Selection of server in upstream directive using hash

rsdrsd October 09, 2017 05:54AM

Re: Selection of server in upstream directive using hash

Roman Arutyunyan October 09, 2017 06:24AM

Re: Selection of server in upstream directive using hash

rsdrsd October 11, 2017 05:48AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 208
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