See the Glassfish cluster blog entry for setting up a Glassfish cluster.
Add the following to make Apache load balance to your Glassfish instances:
RewriteEngine On ProxyRequests Off <Proxy *> Order deny,allow Allow from all </Proxy> <Location /balancer-manager> SetHandler balancer-manager </Location> <Proxy balancer://mycluster> BalancerMember http://10.1.1.2:8080 route=w1 BalancerMember http://10.1.1.3:8080 route=w2 BalancerMember http://10.1.1.4:8080 route=w3 </Proxy> <Location /clusterjsp> Order allow,deny Allow from all </Location> ProxyPass /clusterjsp balancer://mycluster/clusterjsp stickysession=JSESSIONID
The next step is to prepare the cluster so it keeps the route. Create a cluster wide JVM option:
Name : jvmRoute Value : ${INSTANCE_ROUTE}
Then for each instance in the cluster, set the appropriate system instance property, eg:
Name : INSTANCE_ROUTE Value : w1
(Glassfish 2)
Posted September 14, 2012