Skip to main content

Glassfish load balancing and session replication with mod_jk

1 reply [Last post]
Anonymous

Hi,
my name is Andrea Negri and I'm a student at Informatic Engineering in
Rome, Italy.

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?).
Thank you very much for the attention,

Andrea Negri

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
calocoj
Offline
Joined: 2003-10-25
Points: 0

Hi Andrea, please show me your httpd.conf (apache)

JSESSIONID change completely not only the last part.

Example of my httpd.conf:
LoadModule jk_module modules/mod_jk.so
# Should mod_jk send SSL information (default is On)
JkExtractSSL On
# What is the indicator for SSL (default is HTTPS)
JkHTTPSIndicator HTTPS
# What is the indicator for SSL session (default is SSL_SESSION_ID)
JkSESSIONIndicator SSL_SESSION_ID
# What is the indicator for client SSL cipher suit (default is SSL_CIPHER)
JkCIPHERIndicator SSL_CIPHER
# What is the indicator for the client SSL certificated? (default is SSL_CLIENT_CERT)
JkCERTSIndicator SSL_CLIENT_CERT
JkWorkersFile conf/workers.properties
JkLogFile /var/log/httpd/balanceador.txt
JkShmFile logs/jk.shm
JkLogLevel info
JkLogStampFormat "[%a %b %d %H:%M:%s %Y] "
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
JkRequestLogFormat "%w %V %T"
JkStripSession Off
JkMount /clusterjsp/* loadbalancer

workers.properties:
worker.list=worker1,worker2,loadbalancer
worker.worker1.type=ajp13
worker.worker1.host=nodo1.bitahead.com
worker.worker1.port=7880
worker.worker1.lbfactor=1
worker.worker1.socket_keepalive=1
worker.worker1.socket_timeout=300
worker.worker2.type=ajp13
worker.worker2.host=nodo2.bitahead.com
worker.worker2.port=7881
worker.worker2.lbfactor=1
worker.worker2.socket_keepalive=1
worker.worker2.socket_timeout=300
worker.loadbalancer.sticky_session=True
#worker.loadbalancer.sticky_session_force=True
worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=worker1,worker2

and my ssl.conf (because i use https)

Listen 443

SSLEngine on
SSLCipherSuite ALL:!ADH:!EXP56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
SSLCertificateFile "/certs/server.crt"
SSLCertificateKeyFile "/certs/server.pem"
JkMount /prueba/* loadbalancer