Note that there are some explanatory texts on larger screens.

plurals
  1. POmemcached-session-manager on AWS
    primarykey
    data
    text
    <p>I've got a website running on Amazon Web Services that is deployed using Elastic Beanstalk and runs on a minimum of 2 EC2 micro instances. An auto scaling policy is in place, so that it can scale up and scale down depending on the the traffic in the website. Because of this auto scaling policy, I wanted to avoid using sticky sessions and for that reason I am using <a href="http://code.google.com/p/memcached-session-manager/" rel="noreferrer">memcached-session-manager</a>. I am using Amazon ElastiCache (small instance) for the memcached server.</p> <p>The configuration in the context.xml is as follows:</p> <pre><code>&lt;Manager className="de.javakaffee.web.msm.MemcachedBackupSessionManager" memcachedNodes="sessions.myinstancecode.0001.use1.cache.amazonaws.com:11211" sticky="false" sessionBackupAsync="false" lockingMode="none" transcoderFactoryClass="de.javakaffee.web.msm.serializer.kryo.KryoTranscoderFactory" /&gt; </code></pre> <p>This works fine when the traffic is low (i.e. less than 10 users online) but sometimes causes the EC2 instance to restart. You can imagine that if the website is currently running on two instances and they both decide to restart at the same time, the website becomes unreachable and it's a big problem. These are the last lines in the tail_catalina.log that is rotated on Amazon S3 before the EC2 instance decides to restart:</p> <pre><code>Jun 13, 2012 12:32:27 AM de.javakaffee.web.msm.BackupSessionTask handleException WARNING: Could not store session 42F9761AC24F826E1FC3F2A834FBF442 in memcached. Note that this session was relocated to this node because the original node was not available. net.spy.memcached.internal.CheckedOperationTimeoutException: Timed out waiting for operation - failing node: sessions.myinstancecode.0001.use1.cache.amazonaws.com/10.194.23.99:11211 at net.spy.memcached.internal.OperationFuture.get(OperationFuture.java:73) at de.javakaffee.web.msm.BackupSessionTask.storeSessionInMemcached(BackupSessionTask.java:230) at de.javakaffee.web.msm.BackupSessionTask.doBackupSession(BackupSessionTask.java:195) at de.javakaffee.web.msm.BackupSessionTask.call(BackupSessionTask.java:120) at de.javakaffee.web.msm.BackupSessionTask.call(BackupSessionTask.java:51) at de.javakaffee.web.msm.BackupSessionService$SynchronousExecutorService.submit(BackupSessionService.java:339) at de.javakaffee.web.msm.BackupSessionService.backupSession(BackupSessionService.java:198) at de.javakaffee.web.msm.MemcachedSessionService.backupSession(MemcachedSessionService.java:967) at de.javakaffee.web.msm.SessionTrackerValve.backupSession(SessionTrackerValve.java:226) at de.javakaffee.web.msm.SessionTrackerValve.invoke(SessionTrackerValve.java:128) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98) at org.apache.catalina.valves.RemoteIpValve.invoke(RemoteIpValve.java:680) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:928) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:539) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:298) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) at java.lang.Thread.run(Thread.java:636) Jun 13, 2012 12:32:28 AM de.javakaffee.web.msm.LockingStrategy onAfterBackupSession WARNING: An error occurred during onAfterBackupSession. net.spy.memcached.internal.CheckedOperationTimeoutException: Timed out waiting for operation - failing node: sessions.myinstancecode.0001.use1.cache.amazonaws.com/10.194.23.99:11211 at net.spy.memcached.internal.OperationFuture.get(OperationFuture.java:73) at de.javakaffee.web.msm.LockingStrategy.onAfterBackupSession(LockingStrategy.java:287) at de.javakaffee.web.msm.MemcachedSessionService.backupSession(MemcachedSessionService.java:970) at de.javakaffee.web.msm.SessionTrackerValve.backupSession(SessionTrackerValve.java:226) at de.javakaffee.web.msm.SessionTrackerValve.invoke(SessionTrackerValve.java:128) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98) at org.apache.catalina.valves.RemoteIpValve.invoke(RemoteIpValve.java:680) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:928) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:539) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:298) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) at java.lang.Thread.run(Thread.java:636) </code></pre> <p>It seems like the Amazon ElastiCache node is failing, but the thing is that, checking on Amazon CloudWatch, I can see that the CPU utilization never went over 8%. Is there any reason why the Amazon ElastiCache node fails, even though it's not being stressed that much? Also, why does Amazon decide to restart (or better: terminate and start a new instance) when Amazon ElastiChace node fails?</p> <p>Any help greatly appreciated.</p> <p>Thanks!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload