Generally speaking, Java web App is mainly used as two areas:
1.api. API is generally stateless, so there is no need to consider the issue of session sharing
2. Traditional Web applications and websites, such as Crm,oa,erp,b2c,bbs. Especially bbs,b2c such an Internet application, a single Tomcat is often unable to meet high concurrency, so need to do cluster. If you do a cluster, you often need to consider the issue of session sharing, because LB (apache/nginx) and so on tend to distribute the same user's requests to different servers
Commonly used servlet containers are tomcat (the old Servlet container, as classic as Apache, currently widely used), jetty (lightweight servlet container with better performance, Google has been widely used a few years ago), etc. Today's main talk about Tomcat's cluster scenario
There are two types of scenarios:
I. Forwarding POLICY: LB sets a fixed policy that is distributed to the fixed server according to IP. Not recommended for use
Pros: Just configure the LB, the Web container does not need to be adjusted
Disadvantage: The card sex is relatively poor. The LB may not be forwarded properly because the departmental machine in the cluster may be down
Two. Session sharing: Each server sharing session, so that users always have access to normal
1.cluster Mode http://tomcat.apache.org/tomcat-6.0-doc/cluster-howto.html
Advantages: Do not change the original session storage mode
Cons: General performance,
Tomcat Cluster and session sharing