Memcached-session-manager Implementing Tomcat session sharing

Source: Internet
Author: User

    • Principle

MSM (Memcached-session-manager) supports TOMCAT6 and TOMCAT7 and uses the Value (Tomcat valve) to track request. When request requests arrive, the Tomcat session is updated to memcached at the end of the memcached load Session,request request to support the sticky and Non-sticky modes for session sharing purposes.

Sticky Mode: Tomcat session is the main session, Memcached to prepare the session. When request requests arrive, the session is loaded from memcached to Tomcat (the Tomcat session is taken directly when the Tomcat Jvmroute is changed); When the request ends, the Tomcat The session is updated to memcached to achieve the purpose of master and standby synchronization.

Non-sticky Mode: Tomcat session for relay session, MEMCACHED1 main session,memcached 2 for the session. When request requests arrive, the session is loaded from memcached 2 to Tomcat, (when there is no session in the container, the main session is loaded from memcached1 to Tomcat, which is only one memcached node, or When the request ends, the Tomcat session is updated to the master memcached1 and Memcached2, and the Tomcat session is cleared MEMCACHED2. To achieve the primary and standby synchronization purposes.


    • Realize
First download memcached-win32-1.4.4-14 + jdk1.7 and install, download apache-tomcat-7.0.57, respectively, the port number is: 8081, 8082 Download the jar package: javolution-5.4.3.1.jar memcached-session-manager-1.6.5.jar

Memcached-session-manager-tc7-1.6.5.jar

Msm-javolution-serializer-1.6.5.jar

Msm-kryo-serializer-1.6.5.jar

Msm-xstream-serializer-1.6.5.jar

: http://code.google.com/p/memcached-session-manager/downloads/list

Spymemcached-2.11.4.jar

The context node in Tomcat Context.xml is incremented:


sticky  mode:

<manager className= " De.javakaffee.web.msm.MemcachedBackupSessionManager "
memcachednodes=" n1:localhost:11211 "
requesturiignorepattern=". */. ( PNG|GIF|JPG|CSS|JS) $ "
sessionbackupasync=" false "
sessionbackuptimeout=" + "
transcoderfactoryclass= "De.javakaffee.web.msm.serializer.javolution.JavolutionTranscoderFactory"
copycollectionsforserialization= "false"/>


Non-sticky mode:

<manager classname= "De.javakaffee.web.msm.MemcachedBackupSessionManager"
Memcachednodes= "n1:localhost:11211"

Sticky= "false"
Requesturiignorepattern= ". * *. (PNG|GIF|JPG|CSS|JS) $ "
Sessionbackupasync= "false"
sessionbackuptimeout= "100"
Transcoderfactoryclass= "De.javakaffee.web.msm.serializer.javolution.JavolutionTranscoderFactory"
Copycollectionsforserialization= "false"/>


Memcached-session-manager Implementing Tomcat session sharing

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.