manually copy the synchronization session

2010-08-26  来源:本站原创  分类:Industry  人气:149 

Session must hear out the development of synchronized, but as not been engaged in practice is another matter.

Such as Sina, Sohu these portals, more than just tens of thousands of daily visitors, but no one site why not crash? But Zan a one of a small station on the 10,000 daily visitors dare, nice bar, the server will definitely storm out. Why is the portal will be fine, because they do cluster and do load balancing, caching done, do a static build, do the cache; but they do after these technologies, Session on how to synchronize it?

This paper to analysis, several commonly used synchronization Session:

1, using the database synchronization session

Doing synchronized multi-server session, if you must use this method if there are two methods:
1, with a low-end computer store build a database of specialized web server session, or, to the special database built in file server, users access web server, the database will be to check what this special session of the situation in order to achieve session synchronization purposes.
2, this approach is to store session tables and other database tables put together, if the Mysql has done a cluster of words, each node must have this form, mysql, and this session's data table to the table real-time synchronization .
Note: Use the database to synchronize the session, will increase the burden on the database, the database would have a place that is prone to bottlenecks, if the session is also inside the database, much worse. The above two methods, first method is better to put the table session open to independent, to reduce the real burden of the database

2: The synchronization session cookie

session is a file stored on the server side of the situation, cookie is a file there is the client situation, how to synchronize it? Method is simple to generate the session the user to access the page into the cookie which is to cookie for the transfer stations. You visit the web server A, create a session cookie put it inside, you are assigned access to the web server B, this time, web server B first determines the server has no such session, and if not, to see the client in the cookie which have no such session, if no, explain session really does not exist, if the cookie inside, put inside the cookie to the web server synchronization sessoin B, so that you can achieve the synchronization of the session.
Note: This method implementation is simple and convenient, it would not increase the burden on the database, but if the client lost the cookie ban, then the session will be impossible to synchronize, so that site will cause losses; cookie security is not high, although it has added a secret, but can still forged.

3: Using memcache synchronization session

memcache can do distributed, without this function, he does not do the session can be used simultaneously. He can be web servers memory together, as a "memory pool", no matter which server generated sessoin can put this "memory pool", the other can be used.
Advantages: in this way to synchronize the session, will not increase the burden on the database, and secure than using cookie greatly improved, the session into memory inside, than to be read from the file much faster.
Disadvantages: memcache memory is divided into many kinds of specifications of the storage block, a block will have size, this approach also determines, memcache can not use the memory will result in memory fragmentation, memory block, if less, will produce memory overflow.

4: Summary

The above three methods are feasible first method, the speed that most affect the system, not recommended;
The second method, the effect is good, but as the existence of potential safety problems;
The third method, personally feel that the third method is the best recommendation we use

Usually chosen as the portal to achieve the third method, the benefits do not have to say, but the difficulty is in Memcache configuration, if it is bigger centers, or recommend the use of a third method, short-term pay in exchange for long-term stability , why not?

相关文章
  • manually copy the synchronization session 2010-08-26

    Session must hear out the development of synchronized, but as not been engaged in practice is another matter. Such as Sina, Sohu these portals, more than just tens of thousands of daily visitors, but no one site why not crash? But Zan a one of a smal

  • synchronization session 2011-05-14

    Website of doing a web cluster, you definitely will first consider the session synchronization, because through load balancing, the same IP to access the same page will be assigned to a different server, if the session is not synchronized, then a log

  • PHP using session_write_close () manually shut down the session 2011-03-21

    If you're accustomed to using session.auto_start function, may sometimes have trouble. Example, to use the session_id () to set the current Session of the ID, and this function must session_start () before calling. Then session_write_close () can use

  • Tomcat 5 cluster SESSION copy of a (Figure) (change) 2010-07-30

    Tomcat 5 server provides clustering and replication SESSION integrated support. The first article in this series will provide you SESSION TOMCAT cluster persistence and replication of the internal working mechanism SESSION A summary of knowledge. I w

  • session synchronization 2011-05-14

    Website Zhong doing a web cluster, you will definitely first consider the session synchronization problem, because through load balancing, the same IP to access the same page would be assigned to a different server, if the session is not synchronized

  • nginx + tomcat cluster load balancing (to achieve session replication) 2010-12-11

    Nginx + tomcat load balancing done Architecture Description Nginx front-end server to do a load balancer, put back the cluster composed of N units tomcat processing services, nginx forwarded through to the back (Note: did not do static and dynamic se

  • apache tomcat 6 cluster load and session replication 2010-03-29

    Inadvertently see the contents of the cluster tomcat 6, the attempt to configure the look, or many problems, hereby record. apache tomcat server and the connection are in fact three: JK, http_proxy and ajp_proxy. This paper describes the most common

  • Session mechanism Xiangjie (jsp-servlet technology) 2010-06-17

    Although the session mechanism web application has been used for a long time, but still many people do not know the nature of session mechanism, as well as the application can not correct the technology. This session will discuss in detail the workin

  • [Change] nginx + tomcat cluster load balancing (to achieve session replication) 2010-09-19

    Keywords: Nginx, Tomcat, clustering, load balancing Transfer from: http://blog.chinaunix.net/u2/83793/showart_1354266.html Architecture Description Nginx front-end server to do a load balancer, back up the cluster composed of N sets tomcat processing

  • The difference between Servlet mechanism of Request.Session.servletContext 2010-11-04

    On the servlet specification itself, servlet can then store data in three different scopes, namely: Request object, Session object and the getServletContext () method returns the servletContext object preservation. The following is my analysis of the

  • Aapche + tomcat load-balancing + Session Replication 2010-12-29

    Today the real test by the server, this, too, need to modify the first alternative described in the article repeated the baseless assertion is now online too much time in this article I will continue to update, we temporarily do not turn. Do not copy

  • Synchronization in Android 2011-01-10

    fanqiang handling, that can be opened to see the site, with source code. http://mylifewithandroid.blogspot.com/2008/02/synchronization-in-android.html Thursday, February 14, 2008 Synchronization in Android Note: Program was written before this exampl

  • tomcat session replication (a) 2011-05-05

    tomcat's session replication broadly divided into two types: all-to-all and backup, look at the all-to-all, mainly to record their own experiences in reading the source code and code process tomcat cluster configuration being ignored. In the tomcat s

  • Detailed Session Author: Lang Yunpeng Software Engineering 2010-12-07

    Detailed Session Author: Lang Yunpeng software engineering 2009-01-13 10:59:45 read 2382 comments 0 Word Count:. Contents: First, the term session Two, HTTP protocol and the state to maintain Third, the cookie mechanism to understand Fourth, understa

  • Geodatabase and ArcSDE 2010-09-08

    ArcGIS 9.2 product launch later, Geodatabase part of the larger changes occurred. This workshop presented are the Geodatabase and ArcSDE 9.2 features. The product composition: 9.1 version, Geodatabase consists of two: Personal Geodatabase and ArcSDE

  • Tuning performance of WebSphere Application Server V7 2011-05-27

    Introduction IBM WebSphere Application Server is a reliable enterprise-class application server that provides a set of core components, resources and services for developers to use in your application. Each application has unique needs, and often use

  • Understanding of the Oracle optimizer 2011-07-26

    A: SQL tuning category 1: enumerate several table connection 2: do not use third-party tools, how to view sql execution plan 3: how to use the CBO, CBO and the difference RULE 4: how to locate important (resource consuming and more) of the SQL 5: How

  • DBA reference to answer questions and pen 2010-12-08

    Transfer http://www.douban.com/group/topic/2665514/ A: SQL tuning category 1: The table lists several connection 2: do not use third-party tools, how to view sql execution plan 3: how to use the CBO, CBO and the difference RULE 4: how to locate impor

  • Front and back-office data transfer 2009-07-01

    Our systems are generally used in MVC architecture, the background processing of data, display data and the future user interaction, but the school WEB development for so long, has not been projects in which data and logic can be cleanly separated. J

  • With regard to the use of hibernate cache 2009-09-04

    To reprint http://blog.csdn.net/woshichenxu/archive/2006/01/22/586361.aspx 1. Hibernate on the issue of cache: 1.1.1. The basic principle of the cache Hibernate cache is divided into two, the first-class stored in the session referred to as a cache,