"From large Web site Technical architecture Book" Session Management for Application server clusters

Source: Internet
Author: User

Because the Load Balancer server may distribute requests to any server on the cluster, it is more complex to ensure that each request gets the correct session than a single computer.

The main methods of session management under cluster environment

1.session replication

Session replication is an early enterprise-level use of a more server cluster session management mechanism. The application server opens the session copy function of the Web container, synchronizes the session object between several servers in the cluster, so that all session information is saved on each server, so that any downtime will not cause the session data loss. When the server uses the session, it is obtained directly from the local.

This way when the application cluster reaches thousands of, there will be bottlenecks, each need to backup session, there is insufficient memory.

2.session Bindings

The hash algorithm, such as Nginx Ip_hash, makes the same IP request distributed to the same server.

This approach does not meet the high availability requirements for the system, because once a server is down, the session on the machine is no longer there, the user requests to switch to another machine after the session, unable to complete the business processing.

3. Use cookies to record session

Session record in the client, each time the server request, the session is placed in the request sent to the server, the server after processing the request and then the modified session response to the client. The client here is a cookie.

Cookies are used to record the disadvantages of a session's page tour, such as limited by the size of the cookie, the information that can be recorded, and each request for a response requires a cookie to be passed, affecting performance, and if the user closes the cookie, access is not normal. But because

Cookies are easy to use, high availability, support the linear scaling of the application server, and most of the session confidence is relatively small, so in fact, many websites are more or less using cookies to record the session.

4.session Server

Session server can solve all the above problems, the use of independent deployment of the session server (cluster) Unified management session, use the server every time read and write session, all access to the session server.

This solution is in fact the application server state separation, divided into a stateless application server and stateful session server, and then for the different characteristics of the two servers to design the architecture respectively.

For stateful session servers, a relatively simple method is to utilize distributed cache (memcached), database, etc. The packaging is based on these products to meet the storage and access requirements of the session.

If the business scenario has higher requirements for session management, such as the use of Session service grassroots single Sign-On (SSO), user servers and other functions, the need to develop a dedicated session service management platform.

"From large Web site Technical architecture Book" Session Management for Application server clusters

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.