A load balancer is typically deployed in front of a cluster. It:
Allows an application or service to be scaled horizontally across multiple physical (or logical) hosts yet still presents the user with a single URL
Insulates the user from host failures or server crashes, when it is used with session replication
Enhances security by hiding the internal network from the user
Application Server includes load balancing plug-ins for popular web servers like Apache, Microsoft Windows IIS, and Sun Java System Web Server.
This section provides instructions on how to download and set up the Web Server software to act as a load balancer to the cluster of Application Servers. To complete this section, you must have sufficient memory to run a Web Server on your system in addition to the Domain Administration Server and the two Application Server instances you have created so far in this guide. A system with 512 Mbytes to 1024 Mbytes of memory is recommended to complete this section.
This topic presents the following steps:
If you already have Web Server software installed, and if you can identify a Web Server instance to serve as the load balancer, note the location of this instance in the file system and skip to Installing the Load Balancer Plug-in.
If you are using Sun Java Enterprise System software, the Web Server is selected for installation automatically when you choose to install the Load Balancer Plug-in. However, you can also install Web Server software using these steps:
Launch the Java Enterprise System installer.
Select the Sun Java System Web Server component in the Component Selection page.
Choose “Configure Now” to be prompted for Web Server Configuration during installation.
When you are prompted, define a default Web Server instance.
Remember the port number you choose for this default Web Server instance. This guide assumes that port 38000 is selected as the HTTP port for default instance.
If you are using a stand-alone Application Server, or if you do not have access to the Sun Java Enterprise System installer, install Web Server software using these steps:
Go to http://www.sun.com/downloads. Scroll down to the Web & Proxy Servers heading and click Web Servers.
Download Web Server 6.1 Service Pack 2 or higher for the locale and platform of your choice.
To download, you must log in with username and password registered with MySunSM, Sun StoreSM, SunSolveSM, or the Online Support Center. If you do not have a login account, you can register online.
Follow the instructions to install Web Server software. You must:
Extract the software from the compressed archive.
Run the setup program. If you need additional information, see the Web Server installation instructions at http://docs.sun.com.
The Web Server installation process configures the Administration Server for Web Server and prompts you to define a default Web Server instance.
Remember the port number you choose for this default web server instance. This guide assumes that port 38000 is selected as the HTTP port for default instance.
The section describes installing the load balancer plug-in for either a Sun Java Enterprise System distribution or a stand-alone Application Server distribution.
Run the installer for the software distribution you are using—Sun Java Enterprise System software or the stand-alone Sun Java System Application Server software.
When you are asked which components you want to install, select Load Balancing Plug-in.
On the Sun Java Enterprise System installer, you must expand the Application Server item to see the Load Balancing Plug-in. It is not selected for installation by default.
Now return to interacting with the Application Server’s Domain Admin Server. You need a shell execution environment for this section.
Create a load balancer configuration called MyLbConfig targeted to the cluster FirstCluster:
asadmin create-http-lb-config --target FirstCluster MyLbConfig
Enable the FirstCluster cluster and the clusterjsp application deployed in it for HTTP load balancing:
asadmin enable-http-lb-server FirstCluster
asadmin enable-http-lb-application --name clusterjsp FirstCluster
Create a health checker for the load balancer, which signals when an instance that goes down recovers.
asadmin create-http-health-checker --interval 10 --config MyLbConfig FirstCluster
The interval is the number of seconds the health checker waits between checks of an unhealthy instance.
Export the configuration to a file loadbalancer.xml.
asadmin export-http-lb-config --config MyLbConfig loadbalancer.xml
Copy loadbalancer.xml to:
Start load balancing by starting or restarting the Web Server.
If the Web Server instance serving as load balancer is not already running, start the Web Server software by executing the start program in the following directory:
If the Web Server instance serving as load balancer is already running, stop the server and start it using the start and stop programs in the following directory:
Once the application is deployed and the load balancer is running, verify that the load balancing is working.
To display the first page of the clusterjsp application, type this URL in your browser:
Replace the localhost variable with the name of the system that the Web Server is running on.
Replace the web_server_port variable with the value of the port attribute of the LS element in web_server_install_dir/https-hostname/config/server.xml. For this example, port 38000 is used.
A page similar to what you saw in To Verify the Application Deployment. appears.
Examine the Session and Host information displayed. For example:
Executed From Server: localhost
Server Port Number: 38000
Executed Server IP Address: 220.127.116.11
Session Created: Day Mon 05 14:55:34 PDT 2005
The Server Port Number is 38000, the Web Server’s port. The load balancer has forwarded the request on the two instances in the cluster.
Using different browser software, or a browser on a different machine, create a new session. Requests from the same browser are “sticky” and go to the same instance.
These sessions should be distributed to the two instances in the cluster. You can verify this by looking at the server access log files located here:
Solaris Java Enterprise System installation:
Linux Java Enterprise System installation:
Windows Java Enterprise System installation:
Stand-alone Application Server installations:
Add a name and value pair (Name=Name Value=Duke) for storing in HttpSession.
Click the “Add to Session Data” button.
Verify that the session data was added
In this section you created an instance to use as a load balancer and set up a load balancing configuration. You also verified load balancing.
To configure and verify HTTP session failover, continue to Chapter 2, Quick Start for Setting Up High Availability Failover. Otherwise continue on to Cleaning Up.