Sun Java System Application Server 9.1 High Availability Administration Guide

What's New in the Load Balancer Plug-in

In Sun Java System Application Server 9.1, the functionality of the load balancer is enhanced to provide increased flexibility and ease-of-use through the following features.

Auto Apply

Application Server allows changes to the load balancer configuration made from the Admin Console to be automatically sent over the wire to the Web Server configuration directory. With previous versions of Application Server, the load balancer configuration had to be exported and then copied over to the web server configuration directory.

Weighted Round Robin

The load balancer enables improved distribution of HTTP requests. The administrator can use an attribute called 'weight' to specify how requests will be proportionately routed to an instance. For example, suppose a cluster has two instances, and the administrator has assigned a weight of 100 to instance x and a weight of 400 to instance y. Now, for every 100 requests, 20 will go to instance x and 80 will go to instance y.

User–defined Load Balancing

Application Server enables the administrator to define a custom policy for distributing HTTP requests. A custom policy defines the load balancing algorithm that the load balancer plug-in must use. In other words, the Administrator can define which Application Server instance will handle an HTTP request. To use this feature, the administrator needs to develop a shared library, which can, for example, be used to evaluate the headers of incoming requests provided to it and in accordance to some criteria, select the instance that can serve the request. This shared library would be loaded by the load balancer.

The shared library must implement an interface as defined in loadbalancer.h, which is available under appserver_install_dir/lib/install/templates.

Application Server also bundles a sample module roundrobin.c that implements the basic round robin algorithm. The administrator can use this sample module as a template to build the shared library. This sample module is also available under appserver_install_dir/lib/install/templates.

ProcedureTo Configure User-defined Load Balancing

  1. Copy roundrobin.c from appserver_install_dir/lib/install/templates to a work directory (for example:/home/user/workspacelb).

  2. Compile roundrobin.c with an ANSI C/C++ compiler (for example Sun Studio compiler or GCC). Be sure to build a dynamic shared library and not a static executable.

    1. If you are using Sun Studio CC Compiler, use the following command to compile:

      cc -G -I<appserver install dir>/lib/install/templates roundrobin.c -o
    2. If you are using GCC, compile the shared library with this command:

      gcc -shared -I<appserver install dir>/lib/install/templates 
      roundrobin.c -o

      Note –

      If you encounter a relocation error, compile again using the option "-fPIC." The command will look like this:

      gcc -shared -fPIC -I <appserver install dir>/lib/install/templates 
      roundrobin.c -o

      On Microsoft Windows, download the Cygwin utility from This utility has GCC bundled with it. Use the following GCC command to create a dynamic link library (dll):

      gcc -shared -I<appserver_install_dir>/lib/install/templates 
      roundrobin.c -o roundrobin.dll
  3. Change loadbalancer.xmlto point to the newly built module. This is how loadbalancer.xml will look after the edit.

    <cluster name="cluster1" policy="user-defined" 
  4. Copy to the web server instance directory.

  5. Start the web server if it is not running or wait till the load balancer is re-configured.