Session management application server clusters

High availability application server architecture design is mainly based on the characteristics of stateless services, but in fact, there is always state of the business .

In transactional e-commerce sites, the need for purchasing information records the user's shopping cart, each time a user requests are increasing the purchase of goods to the shopping cart;

In the social networking site, you need to record the current logged in user.

These Web applications in the context object is referred to using multiple requests to modify the session (the Session) , stand-alone case, Session Manager may be deployed on a Web server container. In a clustered environment, due to the load balancing servers might distribute requests to the cluster of any one application server, so ensure much more complex with each request is still possible to obtain accurate than stand-alone Session.

Cluster environment, the primary means of Session Management are the following:

  • Session Replication
  • Session binding (session stickiness)
  • Session Server

Next, we introduced one by one.

A, Session Copy

Session for synchronization between servers, each server has all users Session information, the user can request to any server.

Here Insert Picture Description
Disadvantages:

  • Take up too much memory
  • The synchronization process consumes network bandwidth and server processor time

Two, Session Binding

Session binding (Sticky Session), also known as sticky session. All requests to configure the load balancer, so that a user are routed to the same server, so that the user can be stored in the server Session. ( At this load balancing server must be working on the HTTP protocol layer, such as a reverse proxy load balancing )

Here Insert Picture Description
Disadvantages:

When the server goes down, you lose all Session on that server.

Three, Session Server

Using a separate Session data storage server, using conventional MySQL, Redis or Memcached use this memory database. This unified management by the Session Server Session.

Here Insert Picture Description
This solution is in fact the state of the application server is separated into stateless and stateful application servers Session server, and then the different properties of the two servers were designed their architecture.

Advantages: In order to make large-scale sites with scalable, clustered application servers typically need to remain stateless, then the application server can not store user session information. Session Server user session information is stored separately, thus ensuring the stateless application server.

Disadvantages: Session to achieve access code.

Reference:

"Large Web Site Technology Framework" - Li Zhihui the

Articles are also illustrations from the book

Guess you like

Origin blog.csdn.net/u013568373/article/details/91396924