Most of the instructions below are obtained from http://tiainen.sertik.net/2011/03/load-balancing-with-glassfish-31-and.html
1. From Glassfish admin, create a new cluster, say cluster1
2. Once cluster1 is created, go to Instances tab, and create 2 new instances, instance1 and instance2
3. Create mod_jk listener, go to Configurations > Network Config > Network Listener , and click on New.
3a. Enter "mod-jk" on Name textbox,
3b. enter 28009 as port number and
3c. make sure you check the JK Listener checkbox. Click Save.
3d. Stop and start the cluster
4. Download Apache 2.2 and mod_jk (http://tomcat.apache.org/download-connectors.cgi), extract Apache 2.2 and mod_jk.so into Apache22/modules directory
5. Add the following to Apache httpd.conf
Include conf/mod-jk.conf
6. create conf/mod-jk.conf
LoadModule jk_module modules/mod_jk.so
# Where to find workers.properties
JkWorkersFile conf/workers.properties
# Where to put jk logs
JkLogFile logs/mod_jk1.log
# Set the jk log level [debug/error/info]
JkLogLevel info
# Select the log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y]"
# JkOptions indicates to send SSK KEY SIZE
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
# JkRequestLogFormat
JkRequestLogFormat "%w %V %T"
# Mount your applications
JkMountFile conf/uriworkermap.properties
# Add shared memory.
# This directive is present with 1.2.10 and
# later versions of mod_jk, and is needed for
# for load balancing to work properly
JkShmFile logs/jk.shm
# Add jkstatus for managing runtime data
JkMount status
Order deny,allow
Deny from all
Allow from 127.0.0.1
7. Create worker.properties with the following information, put the correct ip address on worker.node1.host
worker.node1.port=28009
worker.node1.host=127.0.0.1
worker.node1.type=ajp13
worker.node1.lbfactor=1
worker.status.type=status
worker.loadbalancer.sticky_session=1
worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=node1
worker.list=loadbalancer,status
8. Create uriworkermap.properties to tell mod_jk which webapp to mount
/=loadbalancer
/*=loadbalancer
/broadleafdemo=loadbalancer
/broadleafdemo/*=loadbalancer
9. Start httpd
