-
Notifications
You must be signed in to change notification settings - Fork 0
ConfigureElastiCache
ElastiCache (http://aws.amazon.com/elasticache/ is a Amazon Cloud service that provides a managed pool of Memcached servers. You can use these just like normal memcached servers but there is a feature which makes it easier. ElastiCache provides "AutoDiscover" which allows you to just use one DNS for the entire pool and not need to manage changing configurations as you add or subtract memcached servers from the pool.
To use ElastiCache with MSM
-
Create an ElastiCache pool with 1 or more nodes http://aws.amazon.com/elasticache/
-
Using the AWS Console (Or API) Find the "Configuration Endpoint" DNS entry. It will look something like : pool.lkxx3b2.cfg.use1.cache.amazonaws.com:11211
This is the single node you will use with MSM
- Build the ElastiCache Cluster Client from this project https://github.com/amazonwebservices/aws-elasticache-cluster-client-memcached-for-java
Or use the pre-built JAR file AmazonElastiCacheClusterClient-no-version.jar
This file is used instead of the spymemcached file spymemcached-2.7.3.jar and is placed in the tomcat/lib directory.
- Configure your tomcat to use a single memcached node with no prefixes.
An example of context.xml
<Manager className="de.javakaffee.web.msm.MemcachedBackupSessionManager"
memcachedNodes="pool.lkxx3b2.cfg.use1.cache.amazonaws.com:11211"
requestUriIgnorePattern=".*\.(ico|png|gif|jpg|css|js)$"
transcoderFactoryClass="de.javakaffee.web.msm.serializer.kryo.KryoTranscoderFactory"
sessionBackupAsync="true"
sticky="true"
copyCollectionsForSerialization="false"
/>
This has been tested with Sticky sessions (load balancer sticky) and async backup.
It should work with non sticky sessions as well but has not yet been tested
You can make sure that the code is detecting the proper nodes by examining the catalina.out file which will show the discovery in process and all the nodes it detects. Adding or removing nodes is automatically detected.
If you are using Elastic Load Balencer (ELB) you can use either the ELB Cookie stickiness or App Cookie stickiness policy. If using the App stickiness policy use the cookie JSESSIONID. Note that this doesnt work with other ways of configuring MSM because those add a suffix to the cookie like "-n1". Using the ElastiCache pool without a prefix defined for memcachedNodes allows the server to use the cookie JSESSIONID without any suffixes