Friday, January 18, 2008

Writing Cluster Application

Here is a checklist of things that need to be done to write good application which would work in Cluster enviroemnt

  • When accessing the cluster from outside using HTTP or RMI verify that access to the cluster is done throught load balancer, this can be either software or hardware load balancer.
  • Consider using 'Optimistic Locking' or 'Pemisitic Locking' if two or more clients may update the same row in the databse at the same time
  • If you want to cache data all over the cluster and not on a single server then don't use Singleton, you would need to user Cache framework such as GigaSpaces or OSCacheor JCache etc', this solution is good mainly for read only data or data which is mostly read.
  • In many application servers you can configure your MDB if it would run on a single server or on several servers.
  • Avoid reading files/writing to files in the code, Since you may run on different hosts in the cluster and the files may not exists on the current host which you are running
  • Use Synchronize where two threads may access the same data at the same time, This problem can also occure on non cluster system.

Please comment if you have other issues which are missing.

1 comment:

Taylor said...

Hi there. Interesting post.

With Terracotta, it is in fact possible to use synchronized in a cluster, in fact writing POJOs and scaling them across the cluster is what Terracotta does. You can use any POJO, and use synchronized. Terracotta manages the locking, so that is also done for you.

Check it out for yourself Terracotta - High Performance Java Clustering

(Note: I do work for Terracotta, however it is free OSS so you can use it however you like)

Links

 
RSS Feeds Submission Directory