Thursday, November 18, 2010

Enable clustering in WSO2 ESB 3.x.x

On this blog post I will guide you on why we need clustering and steps to follow to enable such in WSO2 ESB. The steps are valid for the releases of 3.x.x

Motivation behind clustering

For Real world Enterprise application deployments; scalability and availability of applications are musts. When it comes to products of middle-ware; as the base becomes the middle-ware product itself this is of utmost important. This has lead clustering a popular key word among deployments.

Clustering enables a group of individual items/products to be engage in transactions together as one item/product. These individual items are known as components of a cluster.

Clustering Behind WSO2-ESB

WSO2-ESB has a clearly defined clustering capability for real-world applications. The setup is clearly defined and just could be get over with by few mins. It's that easy.....

You can download the latest WSO2-ESB from here

Step 1
------------
Extract the downloaded WSO2-ESB to folders Cluster_1 and Cluster_2. If you are setting up both the clusters in your local machine you will have to follow the following step in order to avoid clashing http,https ports, else just skip to Step 2.

I will keep the default ports as it is in Cluster_1 and fillowing changes should be made to Cluster_2 folder.

- Go to Cluster_2/wso2esb-3.x.x/repository/conf and open axis2.xml

In the TansportIns section change the default message in-port http 8280 as 8281 or any other; and https port as 8243 as 8241 or any other avoiding conflicts in ports.



Now, you will also have to change the http/https transports of the distributions so that it wont collide;

- Go to Cluster_2/wso2esb-3.x.x/repository/conf and open mgt-transport.xml

In this, change default Admin Console port http 9763 as 9764 or any other; and https port as 9443 as 9444 or any other avoiding conflicts in ports




Step 2
------------

Now we have to enable clustering for both Cluster_1 and Cluster_2 , wso2esb distributions.

- Go to Cluster_1/wso2esb-3.x.x/repository/conf and open axis2.xml

- Browse using the command 'Cluster"

<clustering class="org.apache.axis2.clustering.tribes.TribesClusteringAgent" enable="false">
Change the parameter ; as True. This is by default made as "False"
The class attribute of the cluster element specifies the main class of the clustering implementation.

AvoidInitation : whether clustering should be initialized automatically on start
up. By default, this is set to true in the wso2 ESB, which will initialize clustering on start up.

domain : Name of the domain of a cluster. All nodes that use the same domain name belongs to the same cluster. By specifying different domain names different clusters can be created.

mcastAddress/mcastPort/mcastFrequency/mcastDropTime : These are parameters which are set globally for the nodes of one cluster.

localMemberhost/localMemberPort : This sugeest that the defined esb distribution specfies its own port and ip-address. Therefore change the localMemberhost to the machine IP from default (127.0.0.1) or comment out if you're setting up in your own machine, and different ports for localMemberPort (e.g. 4000 and 4001) for the Cluster_1 and Cluster_2.

After the changes, your axis2.xml Clustering configuration would look like something below or similar.


Step 3
------------

You are all set to go in to a cluster mode. You may no 'cd' to the Cluster_1/wso2esb-3.x.x/bin and Cluster_2/wso2esb-3.x.x/bin directory and start the setup by following command

./wso2server.sh (In Unix) ./wso2server.bat (In Windows)

Upon successful enabling of the cluster you will note the following details on the console of Cluster_2.




Clustering Example - A Load Balancing system
----------------------------------------------------------------------------------------

WSO2 ESB, can be used to achieve high availability within a clustered ESB.

Imagine a case where, all client requests are always directed to a primary node via the load balancer. Node 2 and Node 3 are kept as back up servers and no requests will be directed under normal operations.

With all three nodes configured as a cluster, when the primary Node fails, the load balancing system will forward to a Node 2 as the primary server with the other as a backups. This will ensure NO data loss within the system ensuring high reliability.

There are whole bunch of examples that could be given with the use of throttling; caching; Failover; validation through the use of WSO2-ESB.

Visit us; http://wso2.org/library/esb , http://wso2.org/support
Talk to us; support@wso2.com

1 comment: