Session Cache Server and the Tomcat cluster architecture concept
Or see my blog CSDN
1. Sessin Cache Server (Session cache server) [SCS]
1) a single SCS: SCS data in the Session cache, multiple application servers share the SCS in the Session; each time a new Session Session or new data update, in addition to the normal cache, also cache has changed the Session ID and data Key to inform the SCS or other perceived synchronization data; through the LRU algorithm, do not use the Session for persistence (files, databases, etc.).
Solve a number of AppServer Session sharing between, Session data can be stored in the SCS on the concentration.
With the increase of Application Server, SCS pressure rising, the number of stored Session will become huge, not enough memory.
Traffic is not suitable for large Web sites.
2) Configure multiple SCS: SCS only synchronization between the new and changing data, all SCS data in the same Session; SCS is equality between one of SCS with data synchronization, the synchronization data to all SCS.
Analysis: only a single physical expansion of SCS. As users increase, Application Server also increases, although the pressure can be reduced by increasing the SCS, but the number of stored Session will become huge, not enough memory, and the need for synchronization of data becomes enormous, affecting network traffic, all SCS bit of a waste to maintain a copy of the same Session, Session such a case similar to the JavaEE server copy of the state.
3) SCS group: the formation of one or more SCS SCS group, the group can be expanded according to demand any number (N), SCS; group SCS slice storage Session, SCS group independent of each other, each group maintaining different SCS The Session, improve performance and memory utilization; SCS group standby (or plane mirror) mode, providing Failover, do HA; Session client configuration group all the SCS, through the algorithms are stored on different servers Session, improve performance, avoid the waste of maintaining Session; SCS group standby (or mirror) Session data between the synchronization (sync only new and changed data); combination of AppServer and load equalizer clusters can improve cluster performance.
SCS group data partitioning based on the idea to improve cluster performance, SCS group through the mirror to achieve high availability and improve cluster performance.
slice storage extension can be saved Session, but also save the object data.
Key for the same Session, and the same corresponding SCS Num is stable.
slice storage algorithm:
(See MemCached distributed algorithm http://zhengdl126.javaeye.com/blog/420521)
A to request the dispersion (or to request the Hash):
This algorithm is about Key's hash value divided by the number of SCS SCS group received more than a few, but decided to tell the Cache data storage where a SCS on, still have key = 1, value = user1 and key = 2, value = user2 two data as an example:
For key = 1, hash value% SCS number = (1% 2) = 1, store SCS 2 on;
For key = 2, hash value% SCS number = (2% 2) = 0, stored on the SCS 1.
Obviously this way, Cache data will be distributed in different SCS on the Consistent Hashing
Details see Annex