Knowledge Base
MilesWeb / Cloud Servers

Tomcat Server Cloud Hosting with MilesWeb PaaS

Approx. read time : 6 min

Though it’s a fact that Java hosting is one of the most popular hosting for creating web applications, even the popularity of Apache Tomcat is growing among developers. Due to this we decided to dive into more details on installing latest version of Tomcat, configuring this Java web server and its load balancing, deploying the application and improving Tomcat security on the MilesWeb PaaS powered by Jelastic.

Create Tomcat Server

The Platform-as-a-Service offers easy steps to install Tomcat.

1. Register and log in to MilesWeb PaaS dashboard.

2. Click on New Environment button to create a new environment.

3. Select the Tomcat version for your application server as shown in the below image. With the cloud platform you can use Apache Tomcat versions – from 6 to the lastest Tomcat version 9 based on your application requirements. You simply need to choose from the versions available in the drop-down list:

After the environment is created, you have the ready to use application server of Tomcat installed there. To confirm if Tomcat is working properly, click on Open in browser button just next to the web server.

When the welcome Tomcat web server page is displayed in your browser, it indicates that the server is properly installed.

The application server operated in a different container (node) which is an isolated virtualized instance provided for a software stack. The container has its dedicated private IP and unique DNS record.

Change Tomcat Version

The version of your installed server can be changed at any time without data loss or configurations by clicking on Redeploy containers button besides the Apache Tomcat server node.

Next select a new version of Tomcat (e.g. Tomcat 8) in the appeared dialog and verify the change.

Tomcat Clustering and Scaling

It is possible to automatically scaling application with MilesWeb PaaS, both horizontally and vertically, as well as setting up Tomcat cluster which gives you a truly flexible hosting environment.

Automatic Vertical Scaling

MilesWeb PaaS allows you to automatically scale vertically, allowing you to dynamically change the number of allocated resources (RAM and CPU) for a server as per its current needs, without any manual intervention. With this feature you never have to pay for the unused resources, ultimately saving your time by handling the architectural changes and load-related adjustments automatically.

To set up the automatic resource consumption with your Tomcat server, open the environment topology wizard and mention the cloudlets’ upper scaling limit (each equals to 128 MiB and 400 MHz) with the help of the slider at the top:

Now your application will work within the limits you have set, leading to less resource consumption when the load is less or increasing them when the load is more. Thus, you need to pay only for the resources that you actually consume and not the unused ones. Learn more about automatic vertical scaling.

Manual Horizontal Scaling

In order to manually add extra Tomcat servers, just click on Change environment topology:

Next, press “+” button in the wizard and add the number of instances needed.

Depending on the hosting provider settings you will be able to add the maximum number of the same-type servers within a single environment layer (usually this limit stands for 16 nodes and can be adjusted by sending a request to support). The exact value can be checked within the Quotas & Pricing > Account Limits information frame.

You might notice that when extra servers are added, Apache Tomcat load balancing is enabled automatically. Load Balancer acts as the frontend which receives all the incoming requests and evenly distributes them between application servers which act as backend.

Get more details about manual horizontal scaling in the documentation.

Automatic Horizontal Scaling

Tunable triggers help to execute the automatic horizontal scaling that examine the changes in the load of application and increase or decrease the nodes due to them.

To set up automatic horizontal scaling, you can configure a trigger using Settings button for the desired environment.

Go to the Monitoring > Auto Horizontal Scaling section.

Triggers for specific stacks and resources (CPU, RAM, Network, Disk) can be configured within your environment separately by clicking on Add button. You simply need to mention the conditions of scaling and apply the changes.

Learn in detail about automatic horizontal scaling in the corresponding document.

Automatic Tomcat Clustering

The application server clustering feature that is embedded offers sessions’ replication between pairs of nodes and removes the need of additional software or Memcached usage for improving the availability of application.

No manual configurations are required for getting multicast replication between pairs of Tomcat servers. If a problem occurs on one of the instances, the users on that instance get automatically moved to the other instance in the cluster.

Turning on the High-Availability button within environment wizard will activate the Tomcat clustering, as shown in the picture below:

Deploy Application to Tomcat Environment

You can deploy Java application to the Tomcat environment in different ways but the most commonly used ways is with Deployment Manager.

1. Open Deployment Manager from the taskbar of MilesWeb PaaS dashboard and click Upload button.

2. Click on Browse to find 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. Select the appropriate environment, mention context (or leave default ROOT value) and start deploying the application.

Note: At this step, you can also add deployment hooks for executing your custom scripts prior to or after the application deployment.

5. After the completion of the process, you can see your project within deployments of the environment.

You can deploy your application to Tomcat in other ways too, for example, using Maven build node via Git/SVN. To dive into details please check the Deployment Guide.

Tomcat Configurations

Under this, we will provide some settings and features that help to optimize your work with Tomcat web server.

Environment Variables

For making your application more portable and flexible, you can use environment variables instead of each time mentioning the required values in the application code. MilesWeb PaaS provides you with several Tomcat default environment variables for the commonly used directories. You can find them in the table below:

System VariableMeaning To view Variable Value Type
HOSTNAMEThe name of your system (computer).echo $HOSTNAME
HISTFILEIt is a name of a file in which command history is saved.echo $HISTFILE
HISTFILESIZEThe maximum number of lines contained in the history file.echo $HISTFILESIZE
HISTSIZEThe total number of commands to remember in the command history. By default, its value is 500.echo $HISTSIZE
CDPATHThe search path for the cd command.echo $CDPATH
HOMEThe home directory of the current user.echo $HOME
BASH_VERSIONIt holds the version of this instance of bash.echo $BASH_VERSION
LANGIt is used to determine the locale category for any category not specifically select with a variable starting with LC_ . echo $LANG
IFSThe Internal Field Separator that is used for word splitting after expansion and to split lines into words with
the read builtin command. The default value is .
echo $IFS
PATHThe search path for commands. It is a colon-separated list of directories in which the shell looks for commands.echo $PATH
PSlYour prompt settings.echo $PS1
TERMYour login terminal type.echo $TERM
export TERM=vt100
SHELLSet path to login shell.echo $SHELL
DISPLAYSet X display name.echo $DISPLAY
export DISPLAY=:0.1
EDITORSet name of default text editor.export EDITOR=/usr/bin/vim
TMOUTThe default timeout for the read builtin command. Also in an interactive shell, the value is interpreted as
the number of seconds to wait for input after issuing the command. If not input provided it will logout user.
echo $TMOUT

You can add custom Tomcat environment variables which are stored in /opt/tomcat/conf/variables.conf file along with the default ones.

Configuration Files

You can get the Tomcat configuration files to edit right from the dashboard. For accessing them, click on the Config button next to the Tomcat server.

Next use available file manager to browse.

In the table below you can check the names and paths to the core Apache Tomcat configuration files.

NAMETYPECLUSTER-IPEXTERNAL-IPPORT(S)AGE
kubernetesClusterIP10.96.0.1 None443/TCP10m
phpClusterIP10.100.59.238None9000/TCP5m

Please, find more about Tomcat server configurations in the linked document.

Tomcat Security Settings

To limit the access to your project deployed to Tomcat server, there are two possible solutions recommended: set up user verification and restrict access to your web application for the certain client IP addresses. You can find more information in the article how to Secure Tomcat Hosting.

The other way is to ensure your applications are using Container Firewall feature for security. It allows you to control the availability of your nodes both from inside and outside of the platform. Find the information to Configure Tomcat container firewall from the article Container Firewall Management.

Multiple Domains on Single Tomcat Server

Multiple domains names can be set up on the Tomcat server for increasing the usability, efficiency and scalability of your application and saving your costs without the need to configure separate instances. Some minor adjustments are required to be done within Tomcat configuration files to implement this as described in the post about multiple domains.

MilesWeb PaaS powered by Jelastic makes Tomcat hosting easy and flexible. You get a wide range of already predefined settings to eliminate the tension about routine tasks, and at the same time it leaves the server fully customizable for specific complex configurations. Get started with effortless Tomcat cloud hosting from MilesWeb PaaS and enjoy the benefits in a turnkey package.

Pallavi Godse
Pallavi is a Digital Marketing Executive at MilesWeb and has an experience of over 4 years in content development. She is interested in writing engaging content on business, technology, web hosting and other topics related to information technology.
Need help? We’re always here for you.
Register Your Free Domain Name
OFFER EXPIRES IN
04
min
59
sec