Sun GlassFish Enterprise Server v3 Administration Guide

ProcedureTo Load Balance Using mod_jk and Enterprise Server

Load balancing is the process of dividing the amount of work that a computer has to do between two or more computers so that more work gets done in the same amount of time. Load balancing can be configured with or without security.

In order to support stickiness, the Apache mod_jk load balancer relies on a jvmRoute system property that is included in any JSESSIONID received by the load balancer. This means that every Enterprise Server instance that is front-ended by the Apache load balancer must be configured with a unique jvmRoute system property.

  1. On each of the instances, perform the steps in To Enable mod_jk.

    If your instances run on the same machine, you must choose different JK ports. The ports must match worker.worker*.port in your file. See the properties file in Example 6–5.

  2. On each of the instances, create the jvmRoute system property of Enterprise Server by using the create-jvm-options(1) subcommand.

    Use the following format:

    asadmin> create-jvm-options "-DjvmRoute=/instance-worker-name"/

    where instance-worker-name is the name of the worker that you defined to represent the instance in the file.

  3. To apply your changes, restart Apache HTTP Server and Enterprise Server.

Example 6–6 httpd.conf File for Load Balancing

This example shows an httpd.conf file that is set for load balancing.

LoadModule jk_module /usr/lib/httpd/modules/ 
JkWorkersFile /etc/httpd/conf/ 
# Where to put jk logs 
JkLogFile /var/log/httpd/mod_jk.log 
# Set the jk log level [debug/error/info] 
JkLogLevel debug 
# Select the log format 
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] " 
# JkOptions indicate to send SSL KEY SIZE, 
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories 
# JkRequestLogFormat set the request format 
JkRequestLogFormat "%w %V %T" 
# Send all jsp requests to GlassFish 
JkMount /*.jsp worker1 
# Send all glassfish-test requests to GlassFish 
JkMount /glassfish-test/* loadbalancer

Example 6–7 File for Load Balancing

This example shows a or file that is set for load balancing. The worker.worker*.port should match with JK ports you created.