title: Spring, Tomcat 8 Ehcache replication across AWS cluster(on EC2 instanse)
body: <p>In my Spring application I use a following cache(<code>ehcache</code>):</p>
  
  <pre><code>&lt;bean id="statelessTicketCache"
          class="org.springframework.security.cas.authentication.EhCacheBasedTicketCache"&gt;
          &lt;property name="cache"&gt;
              &lt;bean id="ehcache" class="net.sf.ehcache.Cache" init-method="initialise"
                  destroy-method="dispose"&gt;
                  &lt;constructor-arg value="casTickets" /&gt;
                  &lt;constructor-arg value="0" /&gt;
                  &lt;constructor-arg value="true" /&gt;
                  &lt;constructor-arg value="false" /&gt;
                  &lt;constructor-arg value="3600" /&gt;
                  &lt;constructor-arg value="900" /&gt;
                  &lt;property name="cacheManager" ref="cacheManager" /&gt;
              &lt;/bean&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  </code></pre>
  
  <p>In this cache I'm storing access tickets to my API back end. Everything works perfectly with a single node Tomcat8. But when I try to use 2 or more instances in my AWS cluster with Load Balancer(ELB) and N Tomcats(on EC2 instances) I ran into the issue that each node operates with own instance of <code>statelessTicketCache</code>. </p>
  
  <p>I need to replicate this <code>ehcache statelessTicketCache</code> across my cluster. Is it possible ? If so, could you please provide a sample configuration for this ?</p>
  
  <p><strong>UPDATED</strong></p>
  
  <p>I think, I'll move out from the <code>Ehcache</code> solution and will try to configure <code>statelessTicketCache</code> with <code>Redis</code>(<code>AWS Elastic cache</code> on Redis engine) and use a following implementation <a href="https://github.com/vnomics/spring-stateless-ticket-cache-redis" rel="nofollow">https://github.com/vnomics/spring-stateless-ticket-cache-redis</a> of Spring CAS Stateless Ticket Cache Redis</p>