Kryo is a fast and efficient object graph serialization framework for Java which is much faster and efficient compared to java serialization.The project is useful any time objects need to be persisted, whether to a file, database, or over the network.Kryo can also perform automatic deep and shallow copying/cloning. This is direct copying from object to object, not object->bytes->object
In one of my previous post I had explained about how to integrate tomcat with memcache for session clustering: http://kulshresht-gautam.blogspot.in/2013/07/integrating-tomcat-with-memcahed-for.html
Now in addition to do that post here I would focus on how to override java serialization with kryo serialization which is more faster and efficient compared to the earlier one [http://code.google.com/p/thrift-protobuf-compare/wiki/Benchmarking ].The aim is still to implement memcached-session-manager but we would use kryo serialization instead of normal java serialization.
First Option :
- As msm is available in maven central (under groupId de.javakaffee.msm) you can just pull it in using the dependency management of your build system. With maven you can use this dependency definition for the kryo-serializer:
<dependency> <groupId>de.javakaffee.msm</groupId> <artifactId>msm-kryo-serializer</artifactId> <version>1.6.5</version> <scope>runtime</scope> </dependency>
Second Option :
- If you're not using a dependency management based on maven repositories then below are the jars you need for kryo serializers. Please download the appropriate jars and put them in $CATALINA_HOME/lib/ .
- memcached-session-manager-${version}.jar
- memcached-session-manager-tc7-${version}.jar
- kryo
- kryo-serializers-0.10.jar
- minlog
- msm-kryo-serializer-1.6.5.jar
- reflectasm-1.01.jar
- asm-3.2.jar
- spymemcached-2.8.12.jar
- couchbase-client-1.1.4.jar
The next task would be to add below entries in $CATALINA_HOME/conf/context.xml
<Context> .................. <Manager className="de.javakaffee.web.msm.MemcachedBackupSessionManager" memcachedNodes="n1:hostname1:11211,n2:hostname2:11211" failoverNodes="n2" requestUriIgnorePattern=".*\.(ico|png|gif|jpg|css|js)$" transcoderFactoryClass="de.javakaffee.web.msm.serializer.kryo.KryoTranscoderFactory" /> </Context>Restart tomcat and you are done.
References:
http://code.google.com/p/kryo/
https://code.google.com/p/memcached-session-manager/