Session Replication via Memcached
Session Replication via Memcached
Create the Environment
1Open the topology wizard
Sign in to the platform dashboard and click Create environment.
2Add application servers and Memcached
Select two or more application-server instances. The source example uses two Tomcat servers together with a Memcached node.
3Name and create the environment
Enter the environment name and click Create. The source example uses memcachedreplication.
After provisioning completes, the environment contains the application-server layer, Memcached, and the platform load-balancing component.
Download Session Manager Libraries
The source tutorial uses Memcached Session Manager for Tomcat and several supporting libraries. Its example versions are:
memcached-session-manager-1.6.2.jarmemcached-session-manager-tc7-1.6.2.jarspymemcached-2.8.4.jarmsm-kryo-serializer-1.6.1.jarkryo-1.03.jarreflectasm-0.9.jarkryo-serializers.jarjoda-time.jarminlog-1.2.jar
Upload Libraries to Tomcat
1Open Tomcat Config
Click Config for the Tomcat application-server layer.
2Upload the required JAR files
Open the lib directory and upload all Memcached Session Manager and dependency JAR files.
Configure context.xml
Open the Tomcat server configuration folder and edit context.xml. Add a Memcached Session Manager definition similar to the source example:
<Context path="" docBase="ROOT">
<Manager
className="de.javakaffee.web.msm.MemcachedBackupSessionManager"
memcachedNodes="n1:host:11211"
requestUriIgnorePattern=".*\.(png|gif|jpg|css|js)$"
sessionBackupAsync="false"
sessionBackupTimeout="100"
copyCollectionsForSerialization="false"
transcoderFactoryClass="de.javakaffee.web.msm.serializer.kryo.KryoTranscoderFactory"
customConverter="de.javakaffee.web.msm.serializer.kryo.JodaDateTimeRegistration"
/>
</Context>
context.xml.Set the Memcached Host
Update the memcachedNodes value with the Memcached hostname and the default Memcached port 11211.
The source example uses:
n1:memcached-memcachedreplication.jelastic.com:11211
In the source workflow, the Memcached hostname is formed by adding the memcached- prefix to the environment hostname displayed beneath the environment name.
memcachedNodes.11211.
Save and Restart Tomcat
Save the updated context.xml and restart the Tomcat node so the new libraries and session-manager configuration are loaded.
