Wednesday, September 07, 2011

Clustered Caching with Tangosol Coherence

(From http://mdavey.wordpress.com/2007/01/16/clustered-caching-with-tangosol-coherence/)
 Below, in no particular order are a few items worth noting about Tangosol:
  • When installing Tangosol, make sure all the nodes are running the same version
  • Don’t use any classes in the component.net packages – Coherence was build with its own development environment, compiler etc. component.net contains these internal components.
  • BetFair a few years ago had 80 nodes running Tangosol Coherence. The largest installation today is around 1000 nodes.
  • Coherence uses TCMP (UDP based) protocol for data movement
  • From an installation perspective, 5 machines is probably the minimum requirement. Lots of RAM for each machine, installed across different racks to reduce the risk. The more machines the Coherence cluster contains, the lower the risk.
  • All machines in the cluster should be configured with identical config files, network settings, NIC’s (full/half duplex) etc.
  • Multi-cast disconnect issues can be as simple as a miss-configured router.
  • Production checklist
  • Near Topology (near-*)
  • During development set TTL=0 and changing the group address and port.
  • Client that come/go from the Coherence cluster should set local storage=false, while cluster servers should set local storage=true
  • NamedCache.putAll is far more efficient that put since it can reduce network hops.
  • Prior to cluster usage, run the multicast test for 24 hours.
  • Use Ethereal or similar to monitor the network to help identify unreliable sockets and NIC configuration issues.
  • Java serialization can be a performance bottleneck, consider using Coherence’s ExternalizableLite and its helper, ExternalizableHelper. Externalizable offers reduced GC and ~6x speed improvement.
  • High ticking volumns can cause problems for any application. In the case of Tangosol, and caching ticks, one possible solution is to queue the incoming ticks, and use a thread pool to insert the ticks into the cache.
Tangosol Coherence as its simplest:
import java.io.IOException;

import java.util.Date;
import com.tangosol.net.CacheFactory;
import com.tangosol.net.Cluster;
import com.tangosol.net.NamedCache;


public class firstExample {
  public static void main(String[] args) throws IOException {
    try {
      Cluster cluster = CacheFactory.ensureCluster();
      System.out.println(cluster);
     
      NamedCache myCache = CacheFactory.getCache(“test”);
      Object existingVale = myCache.put(“message”, “someMesasge “ + new Date());

      System.out.println(“Existing Val :” + existingVale);

      Object val = myCache.get(“message”);
      System.out.println(“Val :” + val);
      System.out.println(“Press any key”);
      System.in.read();
    }finally {
      CacheFactory.shutdown();
    }
  }
}

No comments: