Welcome! Log In Create A New Profile

Advanced

Re: Upstream Consistent Hash Inconsistency

Ari Croock
February 11, 2021 03:56AM
Thanks for the explanation.

I don't think changing the current implementation would be a good idea, but
what do you think of adding another option in addition to "consistent"?
It could use the consistent hashing algorithm with peer IP addresses
instead of hostnames, as you suggested.
Not sure what the nginx policy is for that sort of change.

If that's not possible, do you think we could at least add a line to the
documentation about this edge case?

Thanks

On Thu, 11 Feb 2021 at 04:22, Maxim Dounin <mdounin@mdounin.ru> wrote:

> Hello!
>
> On Wed, Feb 10, 2021 at 07:03:30PM +0200, Ari Croock wrote:
>
> > That makes sense to me, except for the fact that "hash" (without
> > "consistent") doesn't seem to be doing round-robin load balancing.
> >
> > Is there a reason that regular "hash" keeps returning a consistent IP? I
> > could understand if both directives resulted in the behaviour you
> > described, but it seems strange that only one would.
>
> That's because the algorithms used are quite different.
>
> Simple hashing algorithm doesn't care about being consistent, and
> uses the Nth peer, where N is calculated as a hash modulo
> total number of peers. This works good as long as the list of
> servers is not changed. If the list is changed, however, new hashing
> will result in completely different peer being used for requests
> with the same hash key. Note that "the list is changed" also
> implies changes in number or order of IP addresses if you use
> names in the configuration.
>
> Consistent hashing works differently: instead, it tries to
> preserve mapping from hash to a particular upstream server. To do
> so, it relies on names used in the configuration, so changes in
> the configuration, such as order of servers, or even changes of IP
> addresses used by particular servers, do not affect distribution
> of the requests between servers. As a result, if a name in the
> configuration maps to more than one IP address, these addresses
> are equal to the algorithm, since they use the same name.
>
> It should be possible to implement consistent hashing differently,
> for example, using IP addresses of the particular peers instead of
> names from the configuration. This approach will probably match
> what you are trying to do somewhat better. This is not how it is
> currently implemented in nginx though.
>
> --
> Maxim Dounin
> http://mdounin.ru/
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>


--
Ari Croock | Isazi | Software Engineer | BSc (Eng) - Electrical

38 Homestead Road, Rivonia, Johannesburg, South Africa, 2128 |(: +27 11 027
6996

*: acroock@isazi.ai | www.isazi.ai
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Upstream Consistent Hash Inconsistency

Ari Croock February 10, 2021 09:22AM

Re: Upstream Consistent Hash Inconsistency

Maxim Dounin February 10, 2021 10:42AM

Re: Upstream Consistent Hash Inconsistency

Ari Croock February 10, 2021 12:04PM

Re: Upstream Consistent Hash Inconsistency

Maxim Dounin February 10, 2021 09:24PM

Re: Upstream Consistent Hash Inconsistency

Ari Croock February 11, 2021 03:56AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 88
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready