Upstream+ip_hash: hash valid global?

Hello,

i have 2 upstreams, each with 3 backend servers, where backendA is the
same
backend in both upstreams.

upstream one {
server backendA;
server backendB;
server backendC;
}

upstream two {
server backendA;
server backendD;
server backendE;
}

A user with his IP sends a request, gets passed to upstream one and is
sent
to backendA. Shortly after that he sends a different request and gets
passed
to upstream two - will he be sent to backendA as well?

So the question is: is ip_hash global in nginx, i.e. a user always is
sent
to the same backend (if available), independent from an upstream? Or is
ip_hash upstream-specific, i.e. nginx hashes per upstream?

thx in advance
revirii

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,243162,243162#msg-243162

hmm… no one? Is this unknown or a secret? At least i wasn’t able to
find
any detailed documentation about this.

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,243162,243259#msg-243259

Hello!

On Mon, Sep 30, 2013 at 08:11:13AM -0400, revirii wrote:

hmm… no one? Is this unknown or a secret? At least i wasn’t able to find
any detailed documentation about this.

It’s an implementation detail. As of now, two identical
upstream{} blocks will map the same ip address to the same peer’s
number. But it’s not something guaranteed.


Maxim D.
http://nginx.org/en/donation.html

Hi,

thanks for your answer :slight_smile:

It’s an implementation detail. As of now, two identical
upstream{} blocks will map the same ip address to the same peer’s
number. But it’s not something guaranteed.

ok, this is the behaviour when the upstreams are identical, i.e. they
have
the same backends. That would be ok for me.

But what if the backends are not identical? My example was:

upstream one {
server backendA;
server backendB;
server backendC;
}

upstream two {
server backendA;
server backendD;
server backendE;
}

If a user sends a request - > upstream:one -> backendA and then makes a
request where upstream:two is used, is he then sent to backendA as well?
Ok,
this would be nice to know, but it’s not that important :wink:

revirii

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,243162,243262#msg-243262

Hello!

On Mon, Sep 30, 2013 at 09:16:14AM -0400, revirii wrote:

server backendD;
server backendE;
}

If a user sends a request - > upstream:one -> backendA and then makes a
request where upstream:two is used, is he then sent to backendA as well? Ok,
this would be nice to know, but it’s not that important :wink:

As long as all servers configured map to the same number of
peers (in most simple case - each “backendX” resolves to a single
ip address) - such backends are identical for the above sentence,
and the request will be sent to “backendA” in both cases.

But, again, this isn’t something guaranteed.


Maxim D.
http://nginx.org/en/donation.html

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs