GlassFish Project - Load Balancer Administration home page

New to GlassFish | Community Guidelines  | Downloads | FAQHow-Tos

Welcome to the Load Balancer Administration page. This page is dedicated to discussing the Clustering and  Load Balancer Administration features in GlassFish. The source code for these features is part of this cvs repository.

Load Balancer Administration News

Page Contents


In order to scale for large amounts of load, it is typical to use multiple server instances in enterprise environments. Typically a load balancer is used in front of these cluster of instances. Please refer to EE quick start guide for more details on clustering. GlassFish does not any place special requirements on the load balancer. Any hardware or software load balancer can be used. GlassFish has documentation on configuring Sun HTTP LB plugin (works on Sun Web Server, Microsoft IIS and Apache), Apache mod_jk, Sun Secure Application Switch and F5 BIG-IP.

Sun HTTP LB plug-in has the following features: The following picture shows Sun HTTP LB plug-in being used in 2 cluster (4 instances on 4 hosts) configuration. Sun HTTP LB plug-in stores its configuration in loadbalancer.xml. Instead of asking users to manually edit this loadbalancer.xml, we can generate loadbalancer.xml. This reduces chances of manual errors. In Glassfish, a load balancer configuration is a named configuration in the domain.xml file. Load balancer configuration can contain clusters or stand alone instances. The following command generates the loadbalancer.xml for cluster by name cluster1.
asadmin configure-http-lb-config --target cluster1 "C:\loadbalancer.xml".

This command will do the following:

The sample generated xml file can be viewed here: loadbalacer.xml. GUI can alse be used to export the LB configuration file. From GUI select HTTP Load Balancers, select New, choose name and targets of the load balancer. You can skip step 2 screen. It is optional and click finish. To export click on the newly created load balancer, choose export tab and click on Export Now button. GUI shows the location where the loadbalancer.xml is generated. Screenshots can be viewed here - creating a load balancer configuration and exporting a load balancer configuration. Once this loadbalancer.xml is copied to Sun HTTP LB installation directory, this configuration is reloaded and the load balancer is ready to forward clusterjsp application requests to the cluster (cluster1).

Load balancer configuration is extremely flexible:

The Configuration Model

New element called  policy and attributes called policy-module and weight are added. For the complete load balancer configuration model, please refer to sun-loadbalancer_1_2.dtd

CLI Commands

Please refer to CLI command reference page for the list of commands available for Load Balancer Administration.


The GlassFish Load Balancer Administration code is located in lb-admin sub module in the repository. The following describes all the sub packages in this module.

The Mbeans sub-package, contains the MBean interface and implementation to manage Load Balancer configuration. CLI and GUI talks to these MBeans.

Reader sub-package contains the code that reads the config elements in domain.xml. These class file use Reader pattern. api package contains the API for the readers and impl package contains the implementation.

Transform  contains the code the implements the Visitors, which visit the above readers and populate the elements in loadbalancer.xml.

We read information from loadbalancer.xml using schema2beans. These generated schema2beans are in  Beans directory.
The logic to the configuration to loadbalancer.xml is in Writer.

Unit/Acceptance Tests

Running the Quicklook tests is required in this section. In addition to the Quicklook tests the Load Balancer Administration module has unit tests developed which need to pass prior to checking in any code. The setup for running unit tests is the same as the Quicklook tests. To run just the Load Balancer Administration unit tests do the following:
Go to glassfish/admin-ee/lb-admin
ant run-all-tests
This will build and run all the all the Load Balancer Administration unit tests including the tests in  tests/com/sun/enterprise/ee/admin/lbadmin .

Supporting Documentation

This section will be updated with useful documents and information about the Load Balancer Administration - Tutorials, Blogs and other useful links.

ToDo List

The following is non-comprehensive list of developer friendly  Load Balancer Administration ToDo features. Please email us if you have questions about current implementation or would like to contribute towards future ToDo list.