Forum: NGINX upstream+ip_hash: hash valid global?

2974d09ac2541e892966b762aad84943?d=identicon&s=25 revirii (Guest)
on 2013-09-26 12:43
(Received via mailing list)
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
2974d09ac2541e892966b762aad84943?d=identicon&s=25 revirii (Guest)
on 2013-09-30 14:12
(Received via mailing list)
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
A8108a0961c6087c43cda32c8616dcba?d=identicon&s=25 Maxim Dounin (Guest)
on 2013-09-30 14:32
(Received via mailing list)
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 Dounin
http://nginx.org/en/donation.html
2974d09ac2541e892966b762aad84943?d=identicon&s=25 revirii (Guest)
on 2013-09-30 15:16
(Received via mailing list)
Hi,

thanks for your answer :-)

> 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 ;-)


revirii

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,243162,243262#msg-243262
A8108a0961c6087c43cda32c8616dcba?d=identicon&s=25 Maxim Dounin (Guest)
on 2013-09-30 17:07
(Received via mailing list)
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 ;-)

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 Dounin
http://nginx.org/en/donation.html
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.