Tomcat Server
Tomcat is by default configured for a development environment and therefore is not
optimized for production on large scalable systems.
But Tomcat is highly configurable and several possible optimization guidelines are
available.
General improvement
Several simple improvements can be achieved by modifying the configuration files of
Tomcat to make it more suitable for a production environment.
Service/daemon
To automate the launch and the execution of Tomcat on a server, it’s possible to
install it as a service (Windows) or run it as a daemon (Linux/Unix).
For more information please refer to the online documentation for Tomcat setup:
http://tomcat.apache.org/tomcat-5.0-doc/setup.html
JVM memory settings
Tomcat runs on top of the Java Virtual Machine and the tomcat scripts are very naïve,
the JVM settings are left for defaults.
Modifying the JVM memory configuration improves Tomcat’s performance in loaded
sites. Normally the JVM allocates an initial size for the Java heap, but it’s possible to
use command line parameters such as Xms and Xmx to set the minimum and maximum
size of the Java heap.
As an example, setting a minimum size of 512M and a maximum size of 1024M for
the Java heap can be done by adding the following code to the CATALINA_OPTS or
the JAVA_OPTS environment variable: -DXms512M –DXmx1024M
Scalability and high availability improvement
In large scale systems, several mechanisms can be implemented to support increasing
numbers of users (scalability) and provide some redundancy to offer higher
availability.
This can be achieved by using clusters and load balancing mechanisms.
Clustering/session replication
To improve the scalability and high availability, it’s possible to setup Tomcat as a
cluster of servers. By definition, a cluster is a group of servers that transparently run if
it they were a single entity.
Tomcat offers some clustering and session replication options described in its online
documentation available at http://tomcat.apache.org/tomcat-5.0-doc/cluster-
howto.html
Load Balancing
Load balancing is a mechanism where the server load is distributed within a system.
Rather than execute an application on a single server, the system executes application
code on a dynamically selected server. When a service is requested, one (or more) of
the cooperating servers is chosen to execute the request. Load balancers act as single
points of entry into the system and direct the traffic to individual web servers.
A set of rules (load balancing policy) can be specified to configure the load balancing.
Tomcat provides several ways to implement load balancing. All of them are described
in the online documentation available at http://tomcat.apache.org/tomcat-5.0-
doc/balancer-howto.html