18

I am doing to a proof of concept using ehcache as the cache provider.

Read somewhere saying we need terracotta server running, ALONG WITH ehcache to provide clustering.

Does ehcache alone provide clustering service or we need terracotta also?

Thanks, Venkat

Alexis Dufrenoy
  • 11,784
  • 12
  • 82
  • 124
Venkat Teki
  • 2,233
  • 4
  • 21
  • 28

3 Answers3

4

If you want the cache (or the caches) to be available from different JVMs you will need Terracotta; ehCache alone cannot do that.

http://www.ehcache.org/documentation/2.7/get-started/about-distributed-cache.html

Of course you could also look at other solutions like Hazelcast.

http://www.hazelcast.com/

Rakesh Chauhan
  • 172
  • 1
  • 5
moodywoody
  • 2,149
  • 1
  • 17
  • 21
  • What can be the best open source solution here? I have similar reuqiremnt where i want to replicate user session. – Sohan Jun 04 '15 at 07:00
4

EhCache is not a distributed solution. So you need to use it with Terracotta to obtain the result you want. Like moodywoody said, you can use Hazelcast, but also Infinispan to obtain this result:

http://www.jboss.org/infinispan

Alexis Dufrenoy
  • 11,784
  • 12
  • 82
  • 124
  • Yes, Infinispan is distributed (peer-to-peer), based on JGroups. Terracotta follows a hub-and-spoke design which is very different. – Manik Surtani Mar 12 '12 at 20:10
  • Hi, my requirement is to just replicate. I have 2 servers in my cache cluster and i want the date to be in sync. i dont need the cache to be distributed. – Venkat Teki Mar 13 '12 at 08:22
  • @Manik Surtani : Sure, Terracotta is a very different solution, but with EhCache, it can be used for the same purpose. – Alexis Dufrenoy Mar 14 '12 at 13:04
  • @venkataratnam: An EhCache cache is related to one JVM. So you need either to use a distributed cache for your different JVMs (Infinispan or Hazelcast), which means multiple caches (for each JVM), synchronized, or to use a clustered JVM (Oracle Coherence or Tarracotta) with one cache. And EhCache works very well with Terracotta. – Alexis Dufrenoy Mar 14 '12 at 13:12
  • @Traroth. Thanks. The same would be applicable to Replicated Cache also right? – Venkat Teki Mar 14 '12 at 13:31
  • @venkataratnam: You mean Replicated Cache Service, for Coherence? I would say so... – Alexis Dufrenoy Mar 14 '12 at 13:34
  • I meant, If i want my cache to be replicated on all the nodes(puts,gets,removes..everything) of the cluster..then also i would need terracotta right? – Venkat Teki Mar 14 '12 at 13:38
  • Actually, with Terracotta, your system will roughly behave like one single JVM running on multiple machines, so you will actually have one cache attached to your Terracotta instance. – Alexis Dufrenoy Mar 14 '12 at 14:18
  • @traroth,This is my understanding.. You can make ehcache clustered using EITHER terracotta OR JGroups/JMS replication.. Please correct me if its wrong – Venkat Teki Mar 15 '12 at 08:36
4

If you don't require clustering, but replication would suffice, ehcache comes with RMI replication bundled and has jgroups as well as JMS replication available:

see http://www.ehcache.org/documentation/2.7/get-started/cache-topologies.html#replicated-caching

Rakesh Chauhan
  • 172
  • 1
  • 5
Alex Snaps
  • 1,230
  • 10
  • 10
  • Hi Alex, i have tried both RMI and JGroups clustering. both seems to be working fine. But do you have any idea which one suits my case best! – Venkat Teki Mar 13 '12 at 13:32
  • Hard to tell, not really knowing all details... JGroups is using multicast, make sure this is something you'll be able to depend on when going into production. – Alex Snaps Mar 14 '12 at 16:09
  • 6
    @AlexSnaps what could be the practical difference (in terms of caching) between clustering and replication?? – thiagoh Oct 09 '13 at 21:14