Article From:https://www.cnblogs.com/czlovezmt/p/9060151.html

The first kind: sticky session

The sticky Session refers to locking the user to a server, such as the example above. When the user first request, the load balancer forwarded the user’s request to the A server. If the load equalizer sets the sticky Session, the user will turn every request.Sending to the A server is equivalent to sticking the user and the A server together. This is the sticky Session mechanism.

Second: server session replication

Principle: session changes on any server (add and delete), which will serialize all the content of the session and broadcast it to all other nodes, regardless of the need for session in other servers, to ensure Session synchronization.

Third kinds: session sharing mechanism

Using distributed caching schemes such as memcached and Redis, however, Memcached or Redis must be clustered.

Principle: different Tomcat specifies access to different master memcached. Information between multiple Memcached is synchronous, capable of master-slave backup and high availability. When users access, first create session in tomcat, and then copy session.Put it on its corresponding memcahed

The fourth: session persistence to the database

Principle: you don’t need to say much, take out a database to store session information. Ensure the persistence of session. Advantages: server problems, session will not lose the disadvantage: if the site has a large amount of access, store session to data.The database will cause great pressure on the database, and additional expenses will be needed to maintain the database.

Fifth kinds of terracotta to implement session replication

Principle: you don’t need to say much, take out a database to store session information. Ensure the persistence of session. Advantages: server problems, session will not lose the disadvantage: if the site has a large amount of access, store session to data.The database will cause great pressure on the database, and additional expenses will be needed to maintain the database.

Leave a Reply

Your email address will not be published. Required fields are marked *