What is the best library for Java to grid/cluster-enable your application? [closed]

There are several:

  • Terracotta (open source, based on Mozilla Public License);
  • Oracle Coherence (formerly Tangosol Coherence; commercial; based on JSR 107, which was never adopted officially);
  • GigaSpaces (commercial; based on JavaSpaces API, part of Jini);
  • GridGain, which you mentioned (open source: LGPL);
  • memcached with a Java client library (open source: BSD License;
  • EHCache (open source: Apache Software License;
  • OSCache (open source: modified Apache License; and
  • no doubt several others.

Now I haven’t used all of these but I’ve used or investigated the majority of them.

GridGain and GigaSpaces are more centred around grid computing than caching and (imho) best suited to compute grids than data grids (see this explanation of compute vs data grids). I find GigaSpaces to be a really interesting technology and it has several licensing options, including a free version and a free full version for startups.

Coherence and Terracotta try to treat caches as Maps, which is a fairly natural abstraction. I’ve used Coherence a lot and it’s an excellent high-performance product but not cheap. Terracotta I’m less familiar with. The documentation for Coherence I find a bit lacking at times but it really is a powerful product.

OSCache I’ve primarily used as a means of reducing memory usage and fragmentation in Java Web applications as it has a fairly neat JSP tag. If you’ve ever looked at compiled JSPs, you’ll see they do a lot of String concatenations. This tag allows you to effectively cache the results of a segment of JSP code and HTML into a single String, which can hugely improve performance in some cases.

EHCache is an easy caching solution that I’ve also used in Web applications. Never as a distributed cache though but it can do that. I tend to view it as a quick and dirty solution but that’s perhaps my bias.

memcached is particularly prevelent in the PHP world (and used by such sites as Facebook). It’s a really light and easy solution and has the advantage that it doesn’t run in the same process and you’ll have arguably better interoperability options with other technology stacks, if this is important to you.

Leave a Comment