0

I am using JBoss EAP 6.2 and Apache 2.2.25-no-ssl for load balancing and clustering deployment of my application.

I want Session Replication off and Sticky session on.

But after doing all sort of configurations, what I noticed that my load balancer not sticking user request based on session-id to one particular node, instead forwarding request to another node.

Below are my cluster configurations.

No of cluster nodes = 2

Apache Load balancer = Apache 2.2.25-no-ssl

App server = JBoss EAP 6.2.0

Apache Load Balancer configuration

workers.properties

# Define list of workers that will be used
# for mapping requests
worker.list=loadbalancer,status

# Define Node1
# modify the host as your host IP or DNS name.
worker.node1.port=8009
worker.node1.host=172.20.150.33
worker.node1.type=ajp13
worker.node1.ping_mode=A
worker.node1.lbfactor=1 

# Define Node2
# modify the host as your host IP or DNS name.
worker.node2.port=8209
worker.node2.host=172.20.150.33
worker.node2.type=ajp13
worker.node2.ping_mode=A
worker.node2.lbfactor=1

# Load-balancing behavior
worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=node1,node2
worker.loadbalancer.sticky_session=1

# Status worker for managing load balancer
worker.status.type=status

uriworkermap.properties

# Simple worker configuration file

# Mount the Servlet context to the ajp13 worker
/*=loadbalancer

mod-jk.conf

# Load mod_jk module
# Specify the filename of the mod_jk lib
LoadModule jk_module modules/mod_jk.so

# Where to find workers.properties
JkWorkersFile conf/workers.properties

# Where to put jk logs
JkLogFile logs/mod_jk.log

# Set the jk log level [debug/error/info]
JkLogLevel debug 

# 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
# The default setting only sends Java application data to mod_jk.
# Use the commented-out line to send all URLs through mod_jk.
# JkMount /* loadbalancer
JkMount /* loadbalancer

# 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 

# You can use external file for mount points.
# It will be checked for updates each 60 seconds.
# The format of the file is: /url=worker
# /examples/*=loadbalancer
JkMountFile conf/uriworkermap.properties

# Add jkstatus for managing runtime data
<Location /jkstatus/>
JkMount status
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Location>

mod-jk.conf loaded in httpd.conf file and Apache runs on port 80.

In JBoss EAP, create two replica named node1 and node2 of standalone folder on same machine as depicted below

enter image description here

Command to start server :

node1

standalone.bat -c standalone-ha.xml -b 172.20.150.33 -u 230.0.10.0 -Djboss.server.base.dir=../node1 -Djboss.node.name=node1 -Dlogging.configuration=file:/${JBOSS_HOME}/node1/configuration/logging.properties

node2

standalone.bat -c standalone-ha.xml -b 172.20.150.33 -u 230.0.10.0 -Djboss.server.base.dir=../node2 -Djboss.node.name=node2 -Dlogging.configuration=file:/${JBOSS_HOME}/node2/configuration/logging.properties -Djboss.socket.binding.port-offset=200

I tried with Session Replication On (by adding in web.xml) but still same problem exists.

Below are my JSESSIONID observations.

on first request

JSESSIONID = SY1d0wVTmX2b-czp50whdmCW.61423f3f-b623-3da4-bd2f-69ba448af636 where 61423f3f-b623-3da4-bd2f-69ba448af636 is JVM-ROUTE for node2.

on second request

JSESSIONID = QMTCTAzt2u-ANTidqZdBIzxO.f742b8d4-46f7-3914-86bb-1044d0a1bfce where f742b8d4-46f7-3914-86bb-1044d0a1bfce is a JVM-ROUTE for node1.

It seems even though jvm-route is appended to primary session id , still load balancer(apache mod-jk) sending request to other node instead of sticking to one on which session established.

Please do helpful.

Ketan
  • 2,612
  • 5
  • 31
  • 44

1 Answers1

0

For this kind of scenario you need to implement this architecture. We are using the same architecture to host Wildfly

Note: Please do not forget to enable session stickiness/connection persistency on Load Balancer(LB) and Apache mod_jk.

In this architecture:

For

   WEB1 -> App1 is Active APP NODE
   WEB2 -> APP2 is Active APP NODE

So if request/connection comes ON LB it is redirected to WEB1. As session stickiness/connection persistency is enabled on LB All requests coming from the same client are redirected to WEB1 only.

Here is my Apache Load Balancer configuration:

workers.properties For node1

# Define list of workers that will be used
# for mapping requests
# The configuration directives are valid
# for the mod_jk version 1.2.18 and later
#
worker.list=loadbalancer,status

# Define Node1
# modify the host as your host IP or DNS name.
worker.node1.port=8009
worker.node1.host=10.62.147.58
worker.node1.type=ajp13
worker.node1.lbfactor=1
#worker.node1.socket_timeout=600
#worker.node1.ping_timeout=1000
worker.node1.ping_mode=A
#worker.node1.connection_pool_timeout=600
worker.node1.redirect=node2


# Define Node2
# modify the host as your host IP or DNS name.
worker.node2.port=8009
worker.node2.host=10.62.147.59
worker.node2.type=ajp13
worker.node2.lbfactor=1
#worker.node2.socket_timeout=600
#worker.node2.ping_timeout=1000
worker.node2.ping_mode=A
#worker.node2.connection_pool_timeout=600
worker.node2.activation=disabled

# Load-balancing behavior
worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=node1,node2
worker.loadbalancer.sticky_session=1
worker.loadbalancer.retry_interval=30
worker.loadbalancer.recover_time=20
#worker.loadbalancer.sticky_session_force=1

# Status worker for managing load balancer
worker.status.type=status

workers.properties For node2

# Define list of workers that will be used
# for mapping requests
# The configuration directives are valid
# for the mod_jk version 1.2.18 and later
#
worker.list=loadbalancer,status

# Define Node1
# modify the host as your host IP or DNS name.
worker.node1.port=8009
worker.node1.host=10.62.147.58
worker.node1.type=ajp13
worker.node1.lbfactor=1
#worker.node1.socket_timeout=600
#worker.node1.ping_timeout=1000
worker.node1.ping_mode=A
#worker.node1.connection_pool_timeout=600
worker.node1.activation=disabled


# Define Node2
# modify the host as your host IP or DNS name.
worker.node2.port=8009
worker.node2.host=10.62.147.59
worker.node2.type=ajp13
worker.node2.lbfactor=1
#worker.node2.socket_timeout=600
#worker.node2.ping_timeout=1000
worker.node2.ping_mode=A
#worker.node2.connection_pool_timeout=600
worker.node2.redirect=node1

# Load-balancing behavior
worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=node1,node2
worker.loadbalancer.sticky_session=1
worker.loadbalancer.retry_interval=30
worker.loadbalancer.recover_time=20
#worker.loadbalancer.sticky_session_force=1

# Status worker for managing load balancer
worker.status.type=status

mod-jk.conf

# Load mod_jk module
# Specify the filename of the mod_jk lib
LoadModule jk_module modules/mod_jk.so

# Where to find workers.properties
JkWorkersFile conf/workers.properties

# Where to put jk logs
JkLogFile logs/mod_jk.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
# Notes:
# 1) Changed from +ForwardURICompat.
# 2) For mod_rewrite compatibility, use +ForwardURIProxy (default since 1.2.24)
# See http://tomcat.apache.org/security-jk.html
JkOptions +ForwardKeySize +ForwardURICompatUnparsed -ForwardDirectories +ForwardURIProxy +ForwardURICompat


# JkRequestLogFormat
JkRequestLogFormat "%w %V %T"

# Mount your applications
#JkMount /__application__/* loadbalancer
# Let Apache serve the images
#JkUnMount /__application__/images/* loadbalancer

# You can use external file for mount points.
# It will be checked for updates each 60 seconds.
# The format of the file is: /url=worker
# /examples/*=loadbalancer
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
# Note: Replaced JkShmFile logs/jk.shm due to SELinux issues. Refer to
# https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=225452
JkShmFile run/jk.shm

JkMount /* loadbalancer
# Add jkstatus for managing runtime data
<Location /jkstatus>
JkMount status
Order deny,allow
Deny from none
Allow from All
</Location>