DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations

Trending

  • Effortlessly Streamlining Test-Driven Development and CI Testing for Kafka Developers
  • Auditing Tools for Kubernetes
  • Fun Is the Glue That Makes Everything Stick, Also the OCP
  • JavaFX Goes Mobile
  1. DZone
  2. Data Engineering
  3. AI/ML
  4. Implement Clustering in CloudHub

Implement Clustering in CloudHub

To ensure High Availability (HA), fault tolerance (FT), scaling, and performance for the application, a cluster can be set up in Mule.

Abhay Yadav user avatar by
Abhay Yadav
·
Aug. 25, 20 · Tutorial
Like (4)
Save
Tweet
Share
5.40K Views

Join the DZone community and get the full member experience.

Join For Free

To ensure High Availability (HA), fault tolerance (FT), scaling, and performance for the application, a cluster can be set up in Mule which acts as a single unit to provide the mentioned capabilities. The instances in a cluster are called nodes that communicate and share a distributed memory grid. Mule uses an active-active model to cluster Mule Runtime engines.


cluster

In case one node goes down, the other node will pick up failed nodes work.

In Active/Active model both the nodes (assuming cluster have two nodes only), are available to handle traffic and in case, one of them goes down, say node A, then the other one/node B will take over the load from its companion (the process is called failover) and when node A comes back up it will take back it's connections and services from node B (called failback) whereas in Active/Passive model only one server (primary node) handles all the traffic while the other node (secondary server) just sits there ready to take over if the primary node fails.

Setting Up Cluster

First, add two servers to the CloudHub. To read about how to add servers, click here

clusters

To add servers to the cluster, all the servers must be in Running state, running the same mule version and same runtime agent version. They shouldn't contain any deployed application/domain. 

Click on Create Cluster

Provide the cluster name, names can contain between 3-40 alphanumeric characters (a-z, A-Z, 0-9) and hyphens (-). They cannot start or end with a hyphen and cannot contain spaces or other characters. Select Unicast or Multicast

  • Unicast
  • Multicast
Advantage of Multicast over Unicast is servers needn't be in running state to be added to the cluster, also nodes can be added to the cluster without restarting it. 

Select Multicast, then click Create Cluster. Anypoint Platform will restart both the servers when Create Cluster is clicked to apply cluster settings. Servers will be not listed under Server panel now, to see them, go to Servers -> Click on Cluster Name.

custer-demo

The server with the Star symbol is the primary/master node. Though there is no primary/master node in the active-active model, one node acts as a primary polling node.

Verify Cluster Setup

Verification of cluster can be done mule_ee logs, but first, the logs for clustering need to be activated in log4j2.xml. In Mule versions from 3.3.x to 4.1.x, there is no need to edit log4j2.xml.

<AsyncLogger name="com.mulesoft.mule.runtime.module.cluster" level="DEBUG"/>
<AsyncLogger name="com.hazelcast.internal.cluster" level="DEBUG"/>

The logs will show the cluster members, their IPs, IDs. Considering the cluster created above, logs will be like below

members

To deploy an App in the cluster, navigate to Application ->Deploy Application. The deployment target should be the cluster. The app will be deployed on both the nodes.

deploy application

Testing Cluster Setup

Create an application with Scheduler as a source and a logger inside for each scope running for 500 iterations.
Java
 




x
11


 
1
<flow name="cluster-demo-appFlow">
2
<scheduler doc:name="Scheduler">
3
<scheduling-strategy >
4
<fixed-frequency/>
5
</scheduling-strategy>
6
</scheduler>
7
<foreach doc:name="For Each" collection="#[(0 to 499)]">
8
<logger level="INFO" doc:name="Logger"message="Server Dir=#[server.userDir]"/>
9
</foreach>
10
<set-payload value="Cluster Demo App" doc:name="Set Payload" />
11
</flow>



The logger inside For Each scope is the printing Server Directory which will be used to identify which node processed the message. Since both the Mule instances are running on the same machine, IP or host can't be used to differentiate between them, hence, using the Server directory. Now deploy the application on the cluster and check the application logs for both the server.

Thanks for reading!

clustering

Published at DZone with permission of Abhay Yadav. See the original article here.

Opinions expressed by DZone contributors are their own.

Trending

  • Effortlessly Streamlining Test-Driven Development and CI Testing for Kafka Developers
  • Auditing Tools for Kubernetes
  • Fun Is the Glue That Makes Everything Stick, Also the OCP
  • JavaFX Goes Mobile

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com

Let's be friends: