Welcome! Log In Create A New Profile

Advanced

Re: session persistance with IP hash

Reinis Rozitis
July 27, 2016 04:46PM
> My understanding is that the ip_hash directive is responsible for session
> persistence. My questions are:
> 1) How long does it last? For example, if I connect and my ip hash tells
> nginx to connect to backend3, will my source IP be forever tied to backend
> 3?

If your IP doesn't change and all the servers are up, you will most likely
always land on the same backend server.
http://nginx.org/en/docs/http/ngx_http_upstream_module.html#ip_hash


> 2) Is there another way to acheive session persistence other than ip hash
> and other than purchasing plus edition?

Yes, you can use different hash mechanisms/keys (for example specific
cookies etc):
https://nginx.org/en/docs/stream/ngx_stream_upstream_module.html#hash

There are also some third-party sticky cookie modules.


I personally preffer to use centralised cache storage (memcache/redis etc)
so it doesn't matter on which server the user lands and they can be used in
roundrobin fashion.


> 3) Is there an ip hash "cache" or something I can clean out periodically
> to force the source IP to get a new hash and therefore a chance to connect
> to a different server?

The standard nginx hash mechanisms don't have any inbuilt "cache". In case
of ip_hash you can change the upstream server order (though it will swap
arround all the users not only particular remote addr).

rr

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

session persistance with IP hash

Brian Pugh July 27, 2016 04:22PM

Re: session persistance with IP hash

Robert Paprocki July 27, 2016 04:36PM

Re: session persistance with IP hash

Reinis Rozitis July 27, 2016 04:46PM

Re: session persistance with IP hash

Brian Pugh July 27, 2016 04:56PM

Re: session persistance with IP hash

Reinis Rozitis July 27, 2016 06:04PM

Re: session persistance with IP hash

Brian Pugh July 27, 2016 09:24PM

Re: session persistance with IP hash

Robert Paprocki July 27, 2016 09:46PM

Re: session persistance with IP hash

Brian Pugh July 28, 2016 10:34AM

Re: session persistance with IP hash

Robert Paprocki July 28, 2016 12:08PM

Re: session persistance with IP hash

Brian Pugh July 28, 2016 12:42PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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