Sun GlassFish Enterprise Server 2.1 High Availability Administration Guide

Setting Up HTTP Load Balancing

This section describes how to set up the load balancer plug-in and includes the following sections:

Prerequisites for Setting Up HTTP Load Balancing

Before configuring your load balancer, you must:


Note –

If you have a deployment scenario where the instances and the load balancer are installed on different network domains, then you must create the node agent by specifying the fully qualified domain name using the option, --agentproperties. For example, asadmin create-node-agent --agentproperties remoteclientaddress=myhost.country.example.com test-na.


Procedure to Set Up HTTP Load Balancing

Use the Admin Console GUI or the asadmin tool to configure load balancing in your environment. The following sections provide you more information.

ProcedureTo Set Up Load Balancing Using the Admin Console

  1. Create a load balancer configuration.

    In the Admin Console, on the left frame, click HTTP Load Balancers and then click New. In the New HTTP Load Balancer page, provide the device details and also select the target cluster or instances.

  2. Add a reference to a cluster or stand-alone server instance for the load balancer to manage.

    To do this using the Admin Console, on the left frame, click the HTTP Load Balancers node and then click the desired load balancer listed under the node. Open the Targets tab, click Manage Targets and in the Manage Targets page, select the required target.

    If you created the load balancer configuration with a target, and that target is the only cluster or stand-alone server instance the load balancer references, skip this step.

  3. Enable the cluster or stand-alone server instance referenced by the load balancer.

    To enable a stand-alone server instance using the Admin Console, on the left frame, click the HTTP Load Balancers node and then click the desired load balancer listed under the node. Open the Targets tab and in the Targets table, click the check box next to the instance you want to enable and click Enable.

    To enable a server instance in a cluster, select the load balancer as explained above and in the Targets tab, click the desired cluster. Now open the Instances tab, select the desired instance, and from the Load Balancer Actions drop down list, select Enable Load Balancing.

    The equivalent command to enable a cluster or a stand-alone instance is asadmin enable-http-lb-server.

  4. Enable applications for load balancing.

    To do this using the Admin Console, open the Targets tab as mentioned above and click the required cluster. Now, open the Applications tab, select the required application and from the More Actions drop-down list, and select Load Balancer Enable.

    These applications must already be deployed and enabled for use on the clusters or stand-alone instances that the load balancer references. Enabling applications for load balancing is a separate step from enabling them for use.

  5. Create a health checker.

    To do this using the Admin Console, open the Targets tab for the load balancer as mentioned in the previous step and in the Targets table, click Edit Health Checker.

    The health checker monitors unhealthy server instances so that when they become healthy again, the load balancer can send new requests to them.


    Note –

    If you are using Sun Java System Web Server (6.1 or 7.0), instead of performing steps 6 and 7, you can generate the load balancer configuration file and send the data over the wire to the Web Server in a single step.

    To do this using the Admin Console, click the desired load balancer and then open the Export tab. In this tab, click Apply Changes Now. This sends the data to the Web Server configuration directory.


  6. Generate the load balancer configuration file.

    To do this using the Admin Console, click the load balancer and then open the Export tab. In this tab, click Export Now.

    This command generates a configuration file to use with the load balancer plug-in shipped with the Sun GlassFish Enterprise Server.

  7. Copy the load balancer configuration file to your web server config directory where the load balancer plug-in configuration files are stored.


    Note –

    To generate the load balancer configuration file automatically and send the data over the wire to the Web Server in a single step, you need to configure Web server for SSL setup and import the DAS certificate. For information on configuring Sun Java System Web Server, see Configuring Sun Web Server.


ProcedureTo Set Up Load Balancing Using the asadmin Tool

  1. Create a load balancer configuration.

    To do this, use the command, asadmin create-http-lb-config.


    Note –

    You can perform all the following steps (Step 2 through Step 7) using a single asadmin command, create-http-lb and its options. For more information about this command, see create-http-lb(1).


  2. Add a reference to a cluster or stand-alone server instance for the load balancer to manage.

    To do this, use the command, asadmin create-http-lb-ref. For more information about this command, see create-http-lb-ref(1).

    If you created the load balancer configuration with a target, and that target is the only cluster or stand-alone server instance the load balancer references, skip this step.

  3. Enable the cluster or stand-alone server instance referenced by the load balancer.

    To do this, use the command asadmin enable-http-lb-server. For more information about this command, see enable-http-lb-server(1).

  4. Enable applications for load balancing.

    To do this, use the command asadmin enable-http-lb-application. For more information about this command, see enable-http-lb-application(1).

    These applications must already be deployed and enabled for use on the clusters or stand-alone instances that the load balancer references. Enabling applications for load balancing is a separate step from enabling them for use.

  5. Create a health checker.

    To do this, use the command, asadmin create-http-health-checker. For more information about this command, see create-http-health-checker(1).

    The health checker monitors unhealthy server instances so that when they become healthy again, the load balancer can send new requests to them.


    Note –

    If you are using Sun Java System Web Server (6.1 or 7.0), instead of performing steps 6 and 7, you can generate the load balancer configuration file and send the data over the wire to the Web Server in a single step.

    To do this using the asadmin tool, set the --autoapplyenabled option of the create-http-lb command to true. For more information about this command, see create-http-lb(1).


  6. Generate the load balancer configuration file.

    To do this, use the command asadmin export-http-lb-config.

    This command generates a configuration file to use with the load balancer plug-in shipped with the Sun GlassFish Enterprise Server.

  7. Copy the load balancer configuration file to your web server config directory where the load balancer plug-in configuration files are stored.


    Note –

    To generate the load balancer configuration file automatically and send the data over the wire to the Web Server in a single step, you need to configure Web server for SSL setup and import the DAS certificate. For information on configuring Sun Java System Web Server, see Configuring Sun Web Server.


HTTP Load Balancer Deployments

You can configure your load balancer in different ways, depending on your goals and environment, as described in the following sections:

Using Clustered Server Instances

The most common way to deploy the load balancer is with a cluster or clusters of server instances. By default all the instances in a cluster have the same configuration and the same applications deployed to them. The load balancer distributes the workload between the server instances and requests fail over from an unhealthy instance to a healthy one. If you’ve configured HTTP session persistence, session information persists when the request is failed over.

If you have multiple clusters, requests can be load balanced across clusters but are only failed over between the instances in a single cluster. Use multiple clusters in a load balancer to easily enable rolling upgrades of applications. For more information, see Upgrading Applications Without Loss of Availability.


Note –

Requests cannot be load balanced across clusters and stand-alone instances.


Using Multiple Stand-Alone Instances

It is also possible to configure your load balancer to use multiple stand-alone instances, and load balance and failover requests between them. However, in this configuration, you must manually ensure that the stand-alone instances have homogenous environments and the same applications deployed to them. Because clusters automatically maintain a homogenous environment, for most situations it is better and easier to use clusters.