Sun Java System Application Server Enterprise Edition 8.2 Quick Start Guide

Setting Up Load Balancing

A load balancer is typically deployed in front of a cluster to accomplish the following:

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 section includes the following topics:

Installing Web Server Software

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.

ProcedureTo Install the Web Server Using the Java Enterprise System Installer

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:

  1. Launch the Java Enterprise System installer.

  2. Select the Sun Java System Web Server component in the Component Selection page.

  3. Choose “Configure Now” to be prompted for Web Server Configuration during installation.

  4. When you are prompted, define a default Web Server instance.

    Tip –

    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.

ProcedureTo Install the Web Server for Stand-Alone Application Server Installations

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:

  1. Go to Scroll down to the Web & Proxy Servers heading and click Web Servers.

  2. Download Web Server for the locale and platform of your choice.

    For a list of the Web Server versions supported, see Sun Java System Application Server Enterprise Edition 8.2 Release Notes.

    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.

  3. Follow the instructions to install Web Server software. You must:

    1. Extract the software from the compressed archive.

    2. Run the setup program. If you need additional information, see the Web Server installation instructions at

  4. The Web Server installation process configures the Administration Server for Web Server and prompts you to define a default Web Server instance.

    Tip –

    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.

Installing the Load Balancer Plug-In

This section describes installing the load balancer plug-in for either a Sun Java Enterprise System distribution or a stand-alone Application Server distribution.

ProcedureTo Install the Load Balancer Plug-in

  1. 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.

  2. 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.

Creating a Load Balancer Configuration

Once the load balancing plug-in is installed, create a load balancer configuration using the Application Server's asadmin command. You need a shell execution environment for this section.

ProcedureTo Create an HTTP Load Balancer Configuration

  1. Create a load balancer configuration called MyLbConfig targeted to the cluster FirstCluster:

    asadmin create-http-lb-config --target FirstCluster MyLbConfig

  2. 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

  3. 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.

  4. Export the configuration to a file loadbalancer.xml.

    asadmin export-http-lb-config --config MyLbConfig loadbalancer.xml

    Because this syntax specifies a file name but not a directory for the loadbalancer.xml file, it is created in the current working directory.

  5. Copy loadbalancer.xml to:


Starting Load Balancing

Start load balancing by starting or restarting the Web Server.

Verifying Load Balancing

Once the application is deployed and the load balancer is running, verify that the load balancing is working.

ProcedureTo Verify Load Balancing

  1. 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.

  2. Examine the Session and Host information displayed. For example:

    • Executed From Server: localhost

    • Server Port Number: 38000

    • Executed Server IP Address:

    • Session Created: Day Mon 05 14:55:34 PDT 2005

  3. 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.

  4. 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:



  5. Add a name and value pair (Name=Name Value=Duke) for storing in HttpSession.

  6. Click Add to Session Data.

  7. Verify that the session data was added.

Next Steps

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.