Nowadays large companies need scalable and continuous applications. As a rule such environments use several server apps. So, if your application is running on multiple servers, you have to share data in some way among these servers or cache your data to get faster response times. Here’s where Hazelcast comes into the game nicely allowing you to easily share and distribute your application data across all nodes of a cluster.
Today’s post is fully focused on clustering. We’ll show you how you can use clustering and data distribution platform Hazelcast on Jelastic cloud. It’s very fast, fail-safe, highly scalable and user-friendly solution. If you need to share data among multiple servers, cluster your Java application, cache your data, provide your servers’ secure communication or fail-safe data management, Hazelcast is what you need.
Hazelcast uses multicast for discovery by default or TCP/IP for environments where multicast is not available. So, Jelastic is a perfect solution for your Hazelcast cluster hosting. Let’s take a look on how these two platforms work together.
1. Log into Jelastic.
2. Create an environment with a Tomcat 7 HA cluster, set up the cloudlet limit and switch on Public IPv4 for it.
Wait a few minutes until your environment is created.
1. Navigate to hazelcast.com and download the latest stable release of the platform.
2. Extract the files from the package you’ve just downloaded.
We will create a simple Java server and client apps using Hazelcast cluster for further deployment into the Jelastic environment we have created earlier.
1. Create your server application Java class and import all the necessary Hazelcast libraries, which are included in the package you’ve downloaded (hazelcast-x.x.x/lib). In our case we use sample Hazelcast application, which starts the first server and uses the customer’s map and queue:
Note: You can see your Public IPs by clicking on the additional button for your server nodes like it’s shown on the next screenshot:
The port number for each node should be the same for the case when you use two different nodes for your cluster.
1. Go back to the Jelastic Dashboard and upload your server app WAR package to the Deployment Manager.
2. Deploy it to the clustered environment you’ve created.
3. Click the Config button for Tomcat and upload hazelcast-all-2.6.jar tothe lib folder.
4. Restart your servers in order to apply new settings.
5. Check your server logs to ensure that your Hazelcast cluster was created.
Note:According to logs you can see that both our Tomcat instances have been successfully clustered and Hazelcast server applications successfully communicate between each other.
6. Run you client application locally. You’ll see that client connects to both servers and gets the size of the map on each Hazelcast cluster node.
As you can see, Jelastiс was specially designed for highly scalable, clustered application hosting. That’s why it so easy to host such apps on our cloud platform. Now developers can save a lot of their time developing and deploying large clusters, especially when application is distributed.