One Client Two Clusters

Sometimes its desirable to have a client connect to multiple clusters, either because the data is dispersed or for instance the clusters are in different locations for high availability. For an extend or external client, which connects to a Coherence cluster via a proxy service over TCP, this is very straight forward. This post outlines how to do this and includes a simple example that you can try yourself. The architecture for this configuration is as follows;

one client two clusters

Unless your client is co-located in the same environment as the different clusters, an extend configuration is preferable. This is because the performance of an extend client will not impact a cluster and when it conencts and disconnects - no data is recovered or re-balanced - and the membership of the cluster will not change.

To configure and extend client to connect to multiple clusters you just need to define a separate cache configuration file for each cluster, where each configuration file contains a mapping from a cache name to that clusters remote address. This allows you to have the same cache name for multiple clusters. An example of the unique elements for the remote cluster configuration is shown below;

multi cache configuration changes

The service name for each remote cluster needs to be unique, though the remote scheme name can be the same. Obviously the remote address will be different for each cluster too.

Each cache configuration file is loaded by a separate ConfiguratbleCacheFactory - so each cluster has its own factory. This factory is then used to instantiate a NamedCache for that cluster, which is completely separate from the NamedCache's for the other clusters. An example of how a seperate NamedCache is created using a distinct ConfiguratbleCacheFactory is shown in the code snippet below;

creating cache factory for different clusters

If you are using POF then the client and each cluster will also need to include the same serialisation information, but that's it, it's pretty simple really.  

Finally, although we have just discussed connecting and interacting with just 2 separate clusters, there could be more than 2 and the client need not be based on Java either, it could be a .NET or C++ client too.

I hope this post has been useful and provides you with some additional options when architecting solutions using Coherence. If you want to try this out you can find a simple 1 client 2 cluster Java example here.

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.