Clustering and Load Balancing in Tomcat 5, Part 2
Tutorial Details:
This is the second part of a series on clustering and load balancing in Tomcat 5 server. In part 1, I provided an overview of large-scale J2EE system design as well as various factors to be considered when designing the system for scalability and high availability. I also discussed Tomcat\'s support for clustering, load-balancing, fault-tolerance, and session-replication capabilities. In this part, we\'ll cover the architecture of a proposed cluster setup and go over the installation and configuration details in deploying the cluster (by running multiple Tomcat server instances).
Proposed Cluster Setup
Listed below are the main objectives that I wanted to achieve in the proposed Tomcat cluster:
Advertisement
*
The cluster should be highly scalable.
*
It should be fault-tolerant.
*
It should be dynamically configurable, meaning it should be easy to manage the cluster declaratively (changing a configuration file) rather than programmatically (changing Java code).
*
It should provide automatic cluster member discovery.
*
Fail-over and load-balancing features for session data with in-memory session state replication.
*
Pluggable/configurable load-balancing policies.
*
Group membership notification when a member of the cluster joins or leaves a group.
*
No loss of message transmission through multicast.
*
Clustering should be seamless to the web application and the server. It should provide both client and server transparency. Client Transparency means that the client is not aware of clustered services or how the cluster is set up. The cluster is identified and accessed as a single thing rather than individual services. And server transparency means that the application code in a server is not aware that it\'s in a cluster. The application code cannot communicate with the other members of cluster.
Four instances of Tomcat server were installed to set up the clustering environment. Tomcat was used for both load balancing and clustering requirements. The cluster setup was done using vertical scaling method (multiple Tomcat server instances running on a single machine). One server group and two clones were configured in the cluster (a server group is a logical presentation of the application server). The clones had same exact configuration (in terms of web application directory structure and contents) as the server group to optimize session replication. To follow are the main components in the proposed cluster setup:
*
Load Balancer: A Tomcat instance is configured to distribute the traffic among cluster nodes. This instance is given a code name TC-LB.
*
Clustering: Three Tomcat server instances were run as part of the cluster. The code names for these instances are TC01, TC02, and TC03.
*
Session Persistence: In-memory session replication was chosen as the session persistence mechanism. The session data was copied to all three cluster members whenever the session object is modified.
*
Fail-Over: The balancer application that comes with Tomcat installation is not designed to handle fail over. I wrote a utility class called ServerUtil to check the server status before forwarding any requests to it. It has two methods to verify the status of a cluster node. In the first method, it uses McastService to check if a specified server instance is currently running or not. The second method verifies a cluster node\'s availability by creating a URL object based on the web page URL passed in as a parameter. To use this class make sure catalina-cluster.jar (located in %TOMCAT_HOME%/server/lib directory) and commons-logging-api.jar (%TOMCAT_HOME%/bin directory) files are specified in the classpath.
Read
Tutorial at: Click here to view the tutorial
Rate Tutorial: Clustering and Load Balancing in Tomcat 5, Part 2
View Tutorial: Clustering and Load Balancing in Tomcat 5, Part 2
Related
Tutorials:
Make room for JavaSpaces, Part 5 - JavaWorld June 2000
Make room for JavaSpaces, Part 5 - JavaWorld June 2000 |
Solid JRun serves
up Java on a budget - JavaWorld June 2000
Solid JRun serves
up Java on a budget - JavaWorld June 2000 |
JDBC drivers in
the wild - JavaWorld July 2000
JDBC drivers in
the wild - JavaWorld July 2000 |
Develop n-tier
applications
using J2EE - JavaWorld December 2000
Develop n-tier
applications
using J2EE - JavaWorld December 2000 |
Take control of the servlet environment, Part 2 - JavaWorld December 2000
Take control of the servlet environment, Part 2 - JavaWorld December 2000 |
Add XML to your J2EE applications - JavaWorld February 2001
Integrate an XML presentation layer in the J2EE layered architecture |
J2EE clustering,
Part 1 - JavaWorld February 2001
J2EE clustering,
Part 1 - JavaWorld February 2001 |
Clean up your wire protocol with SOAP, Part 2 - JavaWorld April 2001
Clean up your wire protocol with SOAP, Part 2 - JavaWorld April 2001 |
Superior app management with JMX - JavaWorld June
Integrate JMX, a reusable configuration framework, with your JSPs |
J2EE clustering,
Part 2 - JavaWorld August 2001
J2EE clustering,
Part 2 - JavaWorld August 2001 |
Develop Java
portlets
Develop Java
portlets |
The Java Web Services Tutorial
This tutorial is a beginner\'s guide to developing Web services and Web applications using the Java Web Services Developer Pack (Java WSDP). |
Clustering and Load Balancing in Tomcat 5, Part 1
The latest version of the Tomcat servlet container provides clustering and load balancing capabilities that are essential for deploying scalable and robust web applications. |
Clustering and Load Balancing in Tomcat 5, Part 2
Clustering and Load Balancing in Tomcat 5, Part 2 |
HA-JDBC: High-Availability JDBC
HA-JDBC: High-Availability JDBC
Summary
HA-JDBC is a JDBC driver proxy that provides light-weight, transparent clustering capability to any underlying JDBC driver.
|
Monitoring Session Replication in J2EE Clusters
Clustering has become one of the most common and most emphasized features of J2EE application servers, because, along with load balancing, it is the fundamental element on which the scalability and reliability of an application server rely. |
Primrose - Free J2EE Database Connection Pooling Software
Primrose
Primrose is a database connection pool, written in Java.
Current containers support are Tomcat 4 & 5, and JBoss 3.
There is also now a standalone version of primrose that can be used for applications not running inside a container.
|
Session Replication in Tomcat 5 Clusters, Part 1
The Tomcat 5 server provides built-in support for clustering and session replication. This first article in this series will provide an overview of session persistence and the inner works of session replication in Tomcat clusters. |
The JavaTM Web Services Tutorial
A beginner's guide to developing Web services and Web applications on the Java Web Services Developer Pack |
High availability Tomcat Connect Tomcat servers to Apache and to each other to keep your site running
If you run only one instance of Tomcat, you lose requests/sessions whenever you upgrade or restart your site. In this article, author Graham King presents simple steps for connecting a pair (or more) of Tomcats to Apache using the JK2/AJP (Apache JServ Pr |
|
|
|