Contents
|
Download the latest memcached-session-manager, memcached-session-manager-tc6, spymemcached,couchbase-client jars from http://code.google.com/p/memcached-session-manager/ and place them in the tomcat lib directory.
[quick@laptop lib]$ pwd /home/quick/tomcat1/lib [quick@laptop lib]$ ls annotations-api.jar couchbase-client-1.1.4.jar jsp-api.jar tomcat-coyote.jar catalina-ant.jar ecj-4.2.2.jar memcached-session-manager-1.6.5.jar tomcat-dbcp.jar catalina-ha.jar el-api.jar memcached-session-manager-tc6-1.6.5.jar tomcat-i18n-es.jar catalina.jar jasper-el.jar servlet-api.jar tomcat-i18n-fr.jar catalina-tribes.jar jasper.jar spymemcached-2.8.12.jar tomcat-i18n-ja.jar
For the builtin java serialization mode, add the following manager configuration to tomcat1/conf/context.xml and update the memcachedNodes.
WEB-INF/web.xml className="de.javakaffee.web.msm.MemcachedBackupSessionManager" memcachedNodes="n1:192.168.1.5:11211,n2:192.168.1.20:11211" failoverNodes="n1" requestUriIgnorePattern=".*\.(ico|png|gif|jpg|css|js)$" transcoderFactoryClass="de.javakaffee.web.msm.JavaSerializationTranscoderFactory" />
Use this instead of the default above for better performance. As per docs, install msm-kryo-serializer, kryo-serializers-0.10 (0.10 is needed, as 0.20+ is for kryo2), kryo, minlog, reflectasm, asm-3.2.
[quick@laptop lib]$ pwd /home/quick/tomcat1/lib [quick@laptop lib]$ ls annotations-api.jar jasper-el.jar msm-kryo-serializer-1.6.5-javadoc.jar asm-3.2.jar jasper.jar reflectasm-1.01.jar catalina-ant.jar jsp-api.jar servlet-api.jar catalina-ha.jar kryo-1.04.jar spymemcached-2.8.12.jar catalina.jar kryo-serializers-0.10.jar tomcat-coyote.jar catalina-tribes.jar memcached-session-manager-1.6.5.jar tomcat-dbcp.jar couchbase-client-1.1.4.jar memcached-session-manager-tc6-1.6.5.jar tomcat-i18n-es.jar ecj-4.2.2.jar minlog-1.2.jar tomcat-i18n-fr.jar el-api.jar msm-kryo-serializer-1.6.5.jar tomcat-i18n-ja.jar
And update transcoderFactoryClass in the context.xml above.
transcoderFactoryClass="de.javakaffee.web.msm.serializer.kryo.KryoTranscoderFactory"
https://github.com/magro/msm-sample-webapp
http://linuxproblems.org/msm-sample-webapp-1.0-SNAPSHOT.war
Enable jmx on tomcat eg:
export JAVA_OPTS="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9004 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false"
Use the following groovy script msm.groovy to print out the JMXStatistics:
[quick@laptop ~]$ groovy msm Catalina:type=Manager,path=/msm-sample-webapp-1.0-SNAPSHOT,host=192.168.1.5 jvmRoute: jvm1 msmStatNumNoSessionModification: 0 msmStatSessionsDeletedFromMemcachedInfo: [Count = 0, Min = 0, Avg = 0.0, Max = 0] sessionAttributeFilter: null msmStatNonStickyAfterLoadFromMemcachedInfo: [Count = 0, Min = 0, Avg = 0.0, Max = 0] msmStatMemcachedUpdateInfo: [Count = 5, Min = 1, Avg = 18.0, Max = 73] entropy: de.javakaffee.web.msm.MemcachedBackupSessionManager@152a656 msmStatBackupInfo: [Count = 5, Min = 5, Avg = 70.4, Max = 242] memcachedNodes: n1:192.168.1.5:11211,n2:192.168.1.20:11211 info: MemcachedBackupSessionManager/1.0 backupThreadCount: 1 distributable: false sessionCreateRate: 0 sessionExpireRate: 0 msmStatNonStickyAcquireLockFailureInfo: [Count = 0, Min = 0, Avg = 0.0, Max = 0] msmStatAttributesSerializationInfo: [Count = 5, Min = 3, Avg = 45.2, Max = 133] enabled: true msmStatNumRequestsWithoutSession: 0 duplicates: 0 sessionIdLength: 16 processingTime: 0 failoverNodes: n1 msmStatCachedDataSizeInfo: [Count = 5, Min = 2829, Avg = 5772.2, Max = 7752] msmStatNonStickyAcquireLockInfo: [Count = 0, Min = 0, Avg = 0.0, Max = 0] msmStatNumTomcatFailover: 0 sessionBackupTimeout: 100 msmStatSessionDeserializationInfo: [Count = 0, Min = 0, Avg = 0.0, Max = 0] msmStatNumNonStickySessionsPingFailed: 0 msmStatNumMemcachedFailover: 0 msmStatNonStickyAfterDeleteFromMemcachedInfo: [Count = 0, Min = 0, Avg = 0.0, Max = 0] msmStatNonStickyAfterBackupInfo: [Count = 0, Min = 0, Avg = 0.0, Max = 0] maxInactiveInterval: 1800 sessionAverageAliveTime: 0 sessionBackupAsync: true initialized: true operationTimeout: 1000 modelerType: de.javakaffee.web.msm.MemcachedBackupSessionManager processExpiresFrequency: 6 sessionCookieName: JSESSIONID algorithm: MD5 maxActive: 1 msmStatNonStickyOnBackupWithoutLoadedSessionInfo: [Count = 0, Min = 0, Avg = 0.0, Max = 0] msmStatEffectiveBackupInfo: [Count = 6, Min = 0, Avg = 6.0, Max = 12] msmStatNumBackupFailures: 0 msmStatNonStickyReleaseLockInfo: [Count = 0, Min = 0, Avg = 0.0, Max = 0] maxActiveSessions: -1 msmStatNumNoSessionAccess: 1 name: MemcachedBackupSessionManager domain: Catalina className: de.javakaffee.web.msm.MemcachedBackupSessionManager msmStatNumNoAttributesAccess: 0 sessionMaxAliveTime: 0 msmStatNumNonStickySessionsReadOnlyRequest: 0 objectName: Catalina:type=Manager,path=/msm-sample-webapp-1.0-SNAPSHOT,host=192.168.1.5 activeSessions: 1 randomClass: java.security.SecureRandom sessionCounter: 1 msmStatSessionsLoadedFromMemcachedInfo: [Count = 0, Min = 0, Avg = 0.0, Max = 0] sticky: true randomFile: /dev/urandom rejectedSessions: 0 msmStatNumRequestsWithSession: 7 expiredSessions: 0
This is a script msmsessions.groovy to list the sessionids, and the creation and last access times for each session:
[quick@laptop ~]$ groovy msmsessions Catalina:type=Manager,path=/msm-sample-webapp-1.0-SNAPSHOT,host=192.168.1.5 D1D5711257D303E26DF9EA7FDF18C986-n2.jvm1: Sun Jun 30 17:03:40 BST 2013, Sun Jun 30 17:41:04 BST 2013 DE1B282F4282B3A0C61B95DC37F20251-n2.jvm1: Sun Jun 30 17:40:57 BST 2013, Sun Jun 30 17:40:57 BST 2013
Memcached