Setting up a session sticky Glassfish cluster

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

    <Location /balancer-manager>
        SetHandler balancer-manager

    <Proxy balancer://mycluster>
       BalancerMember route=w1
       BalancerMember route=w2
       BalancerMember route=w3

    <Location /clusterjsp>
        Order allow,deny
        Allow from all

    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:

    Value : w1

(Glassfish 2)

Posted September 14, 2012