How to keep a session consistent across Web cluster?
The load balancing strategy of nginx can be configured to ip_hash.
The basic idea is Hash(client_ip)%nodes.
Sol 1 is easy to configure and can be adopted in middle-scale distributed environment,
no changing the code.
Tomcat server supports cluster through modifying the two configuration files below:
a. server.xml, just opening the <Cluster> node.
b. web.xml, adding <distributable> node.
Sol 2 is applied in small-scale distributed environment, no changing the code.
Redis is used as the concentrated cache to store the sessions from all web servers.
Sol 3 is the first choice in large-scale distributed application because it is scalable and robust,
but changing the code.
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/32498/viewspace-2641474/ ,如需转载,请注明出处,否则将追究法律责任。