The problem is this, there are two applications, the two applications have mutual invocation relationship, and is a two-way call, a will call B,b will also call a, and through the nginx to the background of the two Tomcat load balancing, the result of the visit will occasionally appear session loss, F12 View route constantly change, prompting for a login error. If the background is a stand-alone tomcat, there is no such problem.
after constant thinking and trying, we thought out two solutions and successfully tested them.
The solution is as follows:
1, modify the Nginx load balancing strategy, from the original sticky changed to Ip_hash;
2, load balance strategy does not move, or use sticky, but sticky to more configuration, as follows:
Upstream loadbalancer_01{
Sticky name=route1;//purpose is to ensure that the name of the two route is not the same
server srv1.example.com;
server srv2.example.com;
server srv3.example.com;
}
Upstream loadbalancer_02{
Sticky name=route2//purpose is to ensure that the name of the two route is not the same
server srv1.example.com;
server srv2.example.com;
server srv3.example.com;
Reason analysis: The two application load Balancer's route name is the same, the default is called route, which results in two application route covering each other.