Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Tomcat Users »

Sticky-sessions problems with mod_jk

G. Wade Johnson

2003-08-13


Versions:
Apache: 1.3.28 Win32
mod_jk/1.2.4

Tomcat 1: 4.1.24
Tomcat 2: 4.1.24

I'm investigating load balancing a Tomcat application that I've been
working on for the last few months. I'm currently having problems with
stick sessions.

My application uses BASIC authentication and Single Signon.

Since I'm a little on the paranoid side, I went through this exercise
fairly slowly.

Using John Turner's docs, the last 6 months of Tomcat Users Archives,
and about a dozen other links from the Tomcat site and the archives,
I've managed the following steps.

1. Using mod_jk and Apache to access Tomcat server with Tomcat and
 Apache both on localhost. No problems.

2. Using mod_jk and Apache to access Tomcat server on a different
 host. No problem.

Now that I'm sure I am not messing up the easy stuff, I moved to load
balancing. I can see that the Apache is definitely sending the
requests to both servers. However, I need the requests to remain
sticky. Currently, the requests bounce randomly between the servers.

Another interesting point is that I get two JSESSIONIDSSO cookies
when I'm trying to do the load balancing (with different paths).
When I'm not doing load balancing, I get one JSESSIONIDSSO cookie
with a path of '/'. Each request to the Apache server goes to a
different Tomcat instance.

The main noticable problem is the need to log in twice. I also
receive new cookies on every request. (Although that would not
bother most people.)

I'm trying to figure out if this is a mod_jk problem, an Apache 1.3
problem, a Windows problem, or my problem.<grin/>

Thanks for any insight into this problem.

Here are appropriate chunks from my configuration files.
--- mod_jk.conf -----
<IfModule !mod_jk.c>
LoadModule jk_module c:/Apache/Apache/modules/mod_jk_1.3.27.dll
</IfModule>

JkWorkersFile "conf/workers.properties"
JkLogFile "logs/mod_jk.log"
JkLogLevel info

<VirtualHost localhost>
  ServerName localhost

  JkMount /IS500/change_password loadbalancer
  JkMount /IS500/normal_state loadbalancer
  JkMount /IS500/update_events loadbalancer
  JkMount /IS500/historical_data loadbalancer
  JkMount /IS500/historical_update loadbalancer
  JkMount /IS500/alarmlist loadbalancer
  JkMount /app/* loadbalancer
  JkMount /Pictures/* loadbalancer
  JkMount /Config/* loadbalancer
</VirtualHost>

--- workers.properties -----
# BEGIN workers.properties
worker.list=loadbalancer

# Load Balancing worker
worker.loadbalancer.type=lb
worker.loadbalancer.balanced_workers=tomcat1,tomcat2
worker.loadbalancer.sticky_session=1

# Local Tomcat
worker.tomcat1.port=8009
worker.tomcat1.host=localhost
worker.tomcat1.type=ajp13
worker.tomcat1.lbfactor=1
worker.tomcat1.cachesize=10
worker.tomcat1.cache_timeout=600
worker.tomcat1.socket_keepalive=1
worker.tomcat1.socket_timeout=300

# HMIRIB3 Tomcat
worker.tomcat2.port=8009
worker.tomcat2.host=testserver
worker.tomcat2.type=ajp13
worker.tomcat2.lbfactor=1
worker.tomcat2.cachesize=10
worker.tomcat2.cache_timeout=600
worker.tomcat2.socket_keepalive=1
worker.tomcat2.socket_timeout=300
# END workers.properties

--- server.xml : Tomcat1 ----
.
.
.
  <Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
         port="8009" minProcessors="5" maxProcessors="75"
         enableLookups="true" redirectPort="8443"
         acceptCount="100" debug="0" connectionTimeout="20000"
      useURIValidationHack="false" disableUploadTimeout="true"
     
protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler"/>
.
.
.
  <Engine jvmRoute="tomcat1" name="Standalone" defaultHost="localhost"
debug="0">
.
.
.


--- server.xml : Tomcat2 ----
.
.
.
  <Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
         port="8009" minProcessors="5" maxProcessors="75"
         enableLookups="true" redirectPort="8443"
         acceptCount="100" debug="0" connectionTimeout="20000"
      useURIValidationHack="false" disableUploadTimeout="true"
     
protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler"/>
.
.
.
  <Engine jvmRoute="tomcat2" name="Standalone" defaultHost="localhost"
debug="0">
.
.
.

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@(protected)
For additional commands, e-mail: tomcat-user-help@(protected)


©2008 junlu.com - Jax Systems, LLC, U.S.A.