Tomcat Server Cloud Hosting with Jelastic PaaS
Apache Tomcat occupies the leading positions among Java servers for running web applications. Considering the demand, we compiled the main details on how to install Tomcat latest version, configure this Java web server and its load balancing, deploy application and improve Tomcat security on the Jelastic PaaS.
Create Tomcat Server
The Platform-as-a-Service provides easy steps for Tomcat installation.
1. Register and log into PaaS dashboard at the chosen hosting service provider.
2. Click New Environment button.
3. Pick desirable Tomcat version for your application server as shown in the picture below. The cloud platform allows you to use Apache Tomcat versions starting from 7 up to the latest Tomcat 9 depending on your application requirements. All you need is to choose from the versions available in the drop down list:
Once the environment is created, you have ready to use Tomcat application server installed there. To check if Tomcat is running, click Open in browser button next to the web server in the environment.
The server is properly installed, so wellcome Tomcat web server page is displayed in your browser.
The application server is operating in a separate container (node) which is an isolated virtualized instance, provisioned for a software stack. The container has its own private IP and unique DNS record.
Change Tomcat Version
If you need to change the version of your installed server, you can do this any time without losing data or configurations. Just click the Redeploy containers button next to the Apache Tomcat server node.
Select a new Tomcat version (e.g. Tomcat 8) in the appeared dialog and confirm the change.
Tomcat Clustering and Scaling
Our PaaS can automatically scale application, both vertically and horizontally, as well as set up Tomcat cluster making hosting truly flexible.
Automatic Vertical Scaling
Automatic vertical scaling is made possible by Jelastic ability to dynamically change the amount of allocated resources (RAM and CPU) for a server according to its current demands, with no manual intervention required. This feature guarantees you never overpay for unused resources and saves your time due to eliminating the necessity of handling the load-related adjustments or architectural changes.
In order to set up automatic resource consumption by your Tomcat server, open the environment topology wizard and specify the upper scaling limit of cloudlets (each equals to 128 MiB and 400 MHz) with the slider located at the top:
Your application will work within these limits reducing resource consumption when the load is down or increasing them when the load is up. Thus, you only pay for the resources that are actually consumed. For more information, please refer to the documentation about automatic vertical scaling.
Manual Horizontal Scaling
For adding extra Tomcat servers manually, just click Change environment topology:
Then press “+” button in the wizard and add the required number of instances.
The maximum number of the same-type servers within a single environment layer depends on a particular hosting provider settings (usually this limit stands for 16 nodes and can be adjusted by sending request to support). You can check the exact value within the Quotas & Pricing > Account Limits information frame.
As you can see, when you add extra servers, Apache Tomcat load balancing is enabled automatically. Load Balancer represents frontend which receives all the incoming requests and evenly distributes them between backends - application servers.
Please, find more details about manual horizontal scaling in the documentation.
Automatic Horizontal Scaling
Automatic horizontal scaling can be implemented by means of tunable triggers, which monitor the changes in application’s load and increase or decrease the number of nodes due to them.
To configure a trigger for the automatic horizontal scaling use Settings button for the desired environment.
Navigate to the Monitoring > Auto Horizontal Scaling section.
By pressing Add button 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 apply changes.
Please, find more details about automatic horizontal scaling in the corresponding document.
Automatic Tomcat Clustering
The embedded application server clustering feature provides replication of sessions between pairs of nodes and eliminates the necessity of additional software or Memcached usage for increasing application availability.
You can get multicast replication between pairs of Tomcat servers without any manual configurations. If one of the instances fails, the users who were on that instance are automatically moved to the other instance in the cluster.
To activate Tomcat clustering, you just need to turn on High-Availability button within environment wizard as shown in the picture below:
Deploy Application to Tomcat Environment
There are several options on how to deploy Java application to the Tomcat environment but the most common way is by means of Deployment Manager.
1. Open Deployment Manager from the taskbar of Jelastic dashboard and click Upload button.
2. Browse to your local file (or use URL to your project) and upload it. The Deployment Manager supports .WAR, .ZIP or .EAR formats.
3. Select your package in the list and click Deploy to button:
4. Choose the appropriate environment, specify context (or leave default ROOT value) and start deploying the application.
5. When the process is completed, you can see your project within deployments of the environment.
In this chapter we will cover some settings and features that help to optimize your work with Tomcat web server.
In order to make your application more portable and flexible, you can use environment variables instead of specifying the required values in the application code each time. Jelastic PaaS provides you with a number of Tomcat default environment variables for the most common stack data. Herewith, you can add custom environment variables for your Tomcat node to make its management even more convenient.
The Tomcat configuration files are available for editing right from the dashboard. In order to access them, press the Config button next to the Tomcat server.
Then use available file manager for browsing.
In the table below you can find the names and paths to the core Apache Tomcat configuration files.
|conf||catalina.policy catalina.properties context.xml|
jaspic-providers.xml jaspic-providers.xsd jelastic-ha.xml
jelastic-ssl.xml logging.properties server.xml
tomcat-env.sh tomcat-users.xml tomcat-users.xsd
Please, find more about Tomcat server configurations in the linked document.
Tomcat Security Settings
In order to restrict access to your project deployed to Tomcat server, we recommend two possible solutions: set up user authentication and deny access to your web application for the certain client IP addresses. The detailed instruction is described in the article on how to Secure Tomcat Hosting.
One more way to ensure the security of your applications is using Container Firewall feature. It lets control your nodes availability both from inside and outside of the platform. Configure Tomcat container firewall using the information from the article Container Firewall Management.
Multiple Domains on Single Tomcat Server
You can set up multiple domain names on the Tomcat server in order to increase the usability, efficiency and scalability of your application, as well as save your costs without having to configure separate instances. For this, make some minor adjustments within Tomcat configuration files as described in the instruction about multiple domains.
As you can see, Jelastic PaaS makes Tomcat hosting easy and flexible. The cloud platform provides a wide range of already predefined settings for you not to bother about routine tasks, and at the same time leaves the server fully customisable for specific complex configurations. Get started with effortless Tomcat cloud hosting from Jelastic PaaS and enjoy the benefits in a turnkey package.