Skip to main content

Glassfish and mod_jk - Load Balancing and Session Replication

No replies
andreaxi
Offline
Joined: 2012-09-11

Hi everyone!
I'm configuring an environment using Glassfish and mod_jk to provide load balancing and session replication.

My worker.properties is as follow:

worker.list=i1,i2,loadbalancer
# default properties for workers
worker.template.type=ajp13
worker.template.port=28080
worker.template.lbfactor=1
worker.template.socket_timeout=300

# properties for node1
worker.i1.reference=worker.template
worker.i1.host=10.0.0.93
#worker.worker1.host=node1

# properties for worker2
worker.i2.reference=worker.template
worker.i2.host=10.0.0.38
#worker.worker2.host=node2

# properties for loadbalancer
worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=i1,i2
worker.loadbalancer.sticky_session=true

The steps I've done are: Created two nodes, n1 and n2 managed centrally (via SSH) from my server:
create-node-ssh --sshuser ubuntu --sshkeyfile /home/ubuntu/acme-auction.pem --nodehost 10.0.0.93 --installdir /home/ubuntu/glassfish3 n1
create-node-ssh --sshuser ubuntu --sshkeyfile /home/ubuntu/acme-auction.pem --nodehost 10.0.0.38 --installdir /home/ubuntu/glassfish3 n2

Created a cluster c1:
create-cluster --properties 'GMS_DISCOVERY_URI_LIST=generate:GMS_LISTENER_PORT=9090' c1
Created two instances:
create-instance --cluster  c1 --node n1 i1
create-instance --cluster  c1 --node n2 i2
start-instance i1
start-instance i2

Created an http-listener and a network-listener

create-http-listener --listenerport 28080 --listeneraddress 0.0.0.0 --defaultvs server jk-connector
create-network-listener --protocol http-listener-1 --listenerport 28080 --jkenabled true --target c1-config jk-connector

Then I created the routes JVM option:
create-jvm-options --target c1 "-DjvmRoute=\${AJP_INSTANCE_NAME}"
...and the sysyem properties according to jvmRoute:

create-system-properties --target i1 AJP_INSTANCE_NAME=i1
create-system-properties --target i2 AJP_INSTANCE_NAME=i2

I expected to be able to use my application visiting server_ip/app_name.

If I look at the cookies I can see:

  • a JSESSIONIDVERSION, format: value:number_of_operation
  • a JSESSIONID, format: value.i1
  • a JREPLICA, format: i2

(or the same with i2 and i1 exchanged). This let me suppose the replication is set correctly, but when I stop i1, what I obtain is a blank page and no changes in cookies (I suppose JSESSIONID should change the last part, ".i1" in ".i2" to make the request be routed to i2, am I wrong?).
Thanks, Andrea