Question

I want to cluster EHCache in Play Framework 2.x web application in several node. Why everyone recommend to avoid to use EHCache as a distributed cache in Play 2.x clustered web application?

I use nginx proxy to serve request across Play node and i want to make default EHCache of each node share its content.

No correct solution

OTHER TIPS

Well according to this EHCache page, using EHCache in distributed mode is a commercial product. So if you want to use a free distributed cache, you need something different like Memcached or Redis.

My experience deploying a (Java)Play 2.2.3 to Amazon EC2 was terrible with EHCache. It requires a few workarounds with the localhost resolve (going su for each of your nodes - hard work when you have a few dozens of servers) and regardless, being free only for standalone version without ostensively letting us know upfront is a big no-no for me. I'm done with EHCache.

Edit: moved to Redis in 2015 (thanks @Traveler)

I am not aware of any Play Framework issues here, but the use of ehcache 2.x should fine as you can set it up with JGroups (faster than RMI) and use invalidation mode (infinispan slang).

Invalidation is a clustered mode that does not actually share any data at all, but simply aims to remove data that may be stale from remote caches. This cache mode only makes sense if you have another, permanent store for your data.

In ehcache 2.x you can set up invalidation mode with replicatePuts=false in your jgroups config.

In ehcache 3.x they do not have such a mode. You have to set up a commercial Terracotta server which is a distributed cache. So all date is moved between nodes and the terracotta server.

We tried it once and failed terribly.

As ehcache2.x is no longer active we just switched to Infinispan which has all features of ehcache2.x and a lot more.

So my recommendation: Use ehcache 2.x or infinispan. Do not use ehcache 3.x

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top