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
[email protected]
http://mailman.nginx.org/mailman/listinfo/nginx