Welcome! Log In Create A New Profile

Advanced

Re: [PATCH] Random peer selection for implicit upstream defined by proxy_pass

Maxim Dounin
September 07, 2012 10:46AM
Hello!

(sorry for late reply, I was busy with OCSP stapling and slowly
catching up with resulting mail backlog now)

On Tue, Aug 21, 2012 at 11:36:49AM -0700, Anton Jouline wrote:

> hello, Nginx developers,
>
> submitting this patch for your review. It changes the behaviour of
> peer selection
> for the case, when the upstream is defined implicitly by proxy_pass
> directive like this:
>
> resolver 172.16.0.23;
> set $backend backend.servers.example.com;
> proxy_pass http://$backend;

[...]

> It turns out that the round-robin algorithm actually does not work in
> this case,
> because of the way things are implemented in src/http/ngx_http_upstream.c.
> The peer array is created and initialized on each request, even if a
> cached result of
> DNS query is returned by resolver. The upstream code has no knowledge of whether
> the list of IP addresses changed or not. So what ends up happening is this:
> Let's say "backend.servers.example.com" resolves to 6 IP addresses. Then the
> first good one will be always used, and the rest will never be even looked at.

Surely this is valid problem, and it needs fixing. Though I don't
think we have to introduce another balancer module just for this.

I think of two possible ways to resolve this:

1. Enforce random order of server in ngx_http_upstream_create_round_robin_peer().
Note it's only used to create upsteams on the fly, so it should be
ok (and will lead to the same result as with your patch, though
will be simplier).

2. Introduce round-robin in resolver code before we return cached
response, much like it will be done by a normal DNS servers. This
should also simplify other possible uses of a resolver.

Not sure which one would be better though.

Maxim Dounin

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[PATCH] Random peer selection for implicit upstream defined by proxy_pass Attachments

Anton Jouline 1418 August 21, 2012 02:38PM

Re: [PATCH] Random peer selection for implicit upstream defined by proxy_pass

Anton Jouline 656 August 27, 2012 11:46AM

Re: [PATCH] Random peer selection for implicit upstream defined by proxy_pass

Maxim Dounin 540 September 07, 2012 10:46AM

Re: [PATCH] Random peer selection for implicit upstream defined by proxy_pass

Anton Jouline 591 September 08, 2012 04:20AM

Re: [PATCH] Random peer selection for implicit upstream defined by proxy_pass

Maxim Dounin 530 September 19, 2012 11:26AM

Re: [PATCH] Random peer selection for implicit upstream defined by proxy_pass

Anton Jouline 539 September 20, 2012 01:40AM

Re: [PATCH] Random peer selection for implicit upstream defined by proxy_pass

Maxim Dounin 518 September 28, 2012 02:52PM

Re: [PATCH] Random peer selection for implicit upstream defined by proxy_pass

Anton Jouline 483 September 28, 2012 04:10PM

Re: [PATCH] Random peer selection for implicit upstream defined by proxy_pass

Maxim Dounin 646 September 29, 2012 03:26AM

Re: [PATCH] Random peer selection for implicit upstream defined by proxy_pass

Anton Jouline 519 September 15, 2012 12:22PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

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