Session sharing

Session sharing


1.Session is saved on the server.
2. Stored in the memory of the server, the StandardManager class of tomcat stores the session in the memory, and can also be persisted to file, database, memcache, redis, etc. The client only saves the sessionid in the cookie, but does not save the session. The session can only be destroyed by invalidate or timeout. Closing the browser will not close the session.
3. Memcached and redis have their own expiration time settings, which are suitable for using land to save


several ideas for session session sharing. I summarize as follows:
1. Store the session data originally stored on the server disk into the client's cookie.
(1) There are advantages and disadvantages to saving data in cookies.
(2) The advantage is that the pressure on the server is reduced, because the session data does not exist on the server disk. There is no problem that the session cannot be read at all.
(3) The disadvantage is: network requests take up a lot. Each time a request is made, the client sends session data to the server through a cookie. Also, browsers have limitations on the size of cookies (4k). Each browser limit is different.

2. To implement the distribution mechanism, also known as sticky mode (sticky session mode), the access requests of the same user are dispatched to the same server.
(1) If the machine hangs up, subsequent requests will still be distributed to this server according to the rules of the session, but it is not available now.
(2)

3. Make an intermediate layer to store all the sessions involved in the access. (That is, all sessions are saved to the same place, rather than a local application server)


If you don't need a session, you can do it yourself, generate an ID and save it in a cookie, get the ID from the cookie when the request comes, get the information corresponding to the ID from the cache, and then use the filter or application to use this information.


Reference Original text (session multi-server sharing scheme): http://www.cnblogs.com/wangtao_20/archive/2013/10/29/3395518.html
Reference original text (How is sessionid generated? By whom? Where is it stored?): http://www.cnblogs.com/woshimrf/p/5317776.html

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326790190&siteId=291194637