Tomcat is an open-source web server and servlet container developed by the Apache Software Foundation, it was initially known as Jakarta Tomcat or Tomcat. If you want to deploy and execute Java applications that are written in Java technologies including Java Servlet, Java Server Pages (JSP), etc, then you require Tomcat. TomEE is built on top of Tomcat. It is the Java Enterprise Edition of Apache Tomcat (Tomcat + Java EE = TomEE).
If you have a website running on a production server with a Tomcat environment, your website might get thousands of web requests per minute. At this point, you most likely feel that the memory resources usage in one Tomcat JVM become overwhelmed. To prevent your server from going down or unresponsive, you can configure a Tomcat cluster by placing two or more Tomcat servers. A cluster is a group of servers that communicate with one another, and the Tomcat instance in a Tomcat cluster is often referred to as a node. Clustering instances of Tomcat make them interconnected.
Implementing Tomcat and TomEE auto clustering in RoseHosting Cloud PaaS is fairly easy. In this guide, we will show you how to configure Tomcat and TomEE clustering automation on RoseHosting Cloud PaaS in a few steps.
Table of Contents
Tomcat/TomEE Auto-Cluster Installation
In this article, we are not going to compare Tomcat and TomEE functionality, however, you can see the comparison table below.
There are many tutorials on how to configure Tomcat/TomEE cluster you can find on the internet, but for some users, they found it complicated and not user-friendly. With RoseHosting Cloud PaaS, we can complete Tomcat or TomEE clustering automation in a few steps.
- Log in to your RoseHosting Cloud PaaS account at https://app.rosehosting.cloud and click on New Environment
- In the topology wizard, choose Tomcat or TomEE among Java application servers and switch on the Auto-Clustering slider. You can adjust anything you want, like the disk limit, scaling limit, etc then click on Create button at bottom right.
- Wait for a few minutes and you will get a notification on your dashboard and an email telling you that the environment has been successfully created.
The new environment is already running. You can see load balancer and application servers in the new environment.
Tomcat / TomEE Cluster Topology
The picture below shows the default cluster topology:
Using the topology as shown in the picture above will ensure that it meets the performance and fault tolerance requirements. NGINX acts as the load balancer in front of the cluster that handles the workload distribution.
Once completed, you can click on the ‘Config’ button under the Application servers
Then navigate to /opt/tomcat/conf/ in directory three on the left and you will find that the “Cluster” element is added to the
/opt/tomcat/conf/tomcat-cluster.xml configuration file:
If you want to check or modify something, you can do it at Configuration File Manager.
Let’s look through this in more detail:
The Tomcat instance is added to the configuration as LocalMember. Other Tomcat nodes in the layer are added by their IPs and unique ID, which are generated using the containers’ IP addresses and IDs.
For relocating sessions, we use the DeltaManager. The session data is spread across all the layer nodes.
For discovering the cluster peers we use the Static membership and the server.xml file on every node also a list of all the cluster members.
The cluster uses TCP protocol on port 4004 to create an interconnection between the nodes – the cluster creation process also adds the firewall rule.
/opt/tomcat/conf/context.xml configuration file, the “org.apache.catalina.ha.context.ReplicatedContext” class is used for the context implementation to allow replication.
The instance creation process generated all these configurations automatically and does not require manual modification.
Tomcat / TomEE Cluster Horizontal Scaling
In RoseHosting Cloud PaaS, enabling Tomcat/TomEE Cluster Horizontal Scaling is fairly easy.
- Click on your Tomcat/TomEE cluster environment then go to Settings > Auto Horizontal Scaling
- Set up scaling triggers for the required resources
In this section, you can configure the scaling limit according to your liking. You can configure the triggers for specific stacks and resources (CPU, RAM, Network, Disk) within your environment separately. Just specify the conditions of scaling and then click on the Apply button to apply the changes.
Please note that the minimum number of worker nodes to run horizontal clustering is 2, you can set up the Scale in limit respectively as in the picture above.
That’s it! You have successfully configured Tomcat/TomEE Auto-Clustering on RoseHosting Cloud PaaS.
Of course, you don’t have to do Tomcat/TomEE Auto-Cluster Installation if you have an account at RoseHosting Cloud PaaS, in which case you can simply ask our expert Linux admins to do Tomcat/TomEE Auto-Cluster Installation for you. They are available 24×7 and will take care of your request immediately. If you do not have an account at RoseHosting Cloud PaaS and are looking for a reliable Tomcat web hosting that offers scalability and high availability, RoseHosting Cloud PaaS auto-clustering is an excellent solution to consider.
PS. If you liked this post, on how to do Tomcat/TomEE Auto-Cluster Installation, please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.