Taobao application of the stateless (Taobao session framework) _session

Source: Internet
Author: User
As the saying goes, the scalability of a system depends on how the application state is managed. Why do you say that? Let's just imagine if we save a lot of state information with the client in the session, what do we do when we save the state information of server downtime? Generally speaking, we solve this problem through the cluster, but the commonly called cluster, not only load balance, more importantly, there should be failure recovery failover, such as Tomcat used in cluster node broadcast replication, JBoss adopted the pairing replication and other session state replication strategy, But the state recovery in the cluster also has its drawbacks, that is seriously affecting the scalability of the system, the system can not be increased by adding more machines to achieve a good level of scaling, because the node session between the nodes will increase the number of nodes and overhead, so in order to achieve the scalability of the application itself, We need to ensure that the application is stateless, so that each node in the cluster is the same, so that the system is a better level of scaling.

OK, above say the importance of state-free, then how to achieve a state-specific. At this point, a session framework works. Fortunately, Taobao already has such a framework. Taobao's session framework uses the client cookie implementation, mainly to save the state to the cookie, so that the application node itself does not need to save any state information, so that when the system user becomes more, You can achieve horizontal scaling by adding more application nodes. However, the use of client-side cookies to save the state also encountered restrictions, such as each cookie can not exceed 4K size, and many browsers limit a site to save up to 20 cookies. Amoy The cookie framework uses a "multivalued cookie", which is the value of a combination of multiple cookies, not only to prevent the number of cookies from exceeding 20, but also to save the cookie's space to store valid information. Because each cookie will have approximately 50 bytes of meta information to describe the cookie by default.

In addition to Taobao's current session framework for the implementation of the way, in fact, centralized session management to complete, said the specific point is multiple stateless application node to connect a session server, session server will save session to the cache, session clothing The back end of the server is equipped with the underlying persistent data source, such as database, file system and so on.

Http://techbbs.zol.com.cn/1/3_1080.html

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.