You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Xu, William [CC]" <wx...@sprintspectrum.com> on 2003/04/14 16:06:57 UTC

Losing Session Affinity on Apache-Tomcat AJP13

I configured one Apache and two Tomcat instances on a Solaris box. The load
balancing seems to work well. However the session affinity is not. I am
certain the JSESSIONID cookie is sent to the browser and sent back with
every request. But AJP13 connector always round robin every request to the
next server.  Could anybody help me figure out what the problem is? Thanks
in advance. Here are my config file snippets:
---------------------------------------------------
Tomcat - server.xml:
---------------------------------------------------

    <!-- Define an AJP 1.3 Connector on port 11009 -->
    
    <Connector className="org.apache.ajp.tomcat4.Ajp13Connector"
               port="11009" minProcessors="5" maxProcessors="75"
               acceptCount="10" debug="0"/>

---------------------------------------------------
Tomcat - worker.properties:
---------------------------------------------------

#
# workers.properties 
#

# In Unix, we use forward slashes:
ps=/

# list the workers by name

worker.list=tomcat1, tomcat2, loadbalancer

# ------------------------
# First tomcat server
# ------------------------
worker.tomcat1.port=11009
worker.tomcat1.host=localhost
worker.tomcat1.type=ajp13

# Specify the size of the open connection cache.
#worker.tomcat1.cachesize

#
# Specifies the load balance factor when used with
# a load balancing worker.
# Note:
#  ----> lbfactor must be > 0
#  ----> Low lbfactor means less work done by the worker.
worker.tomcat1.lbfactor=100


# ------------------------
# Second tomcat server
# ------------------------
worker.tomcat2.port=11009
worker.tomcat2.host=207.40.170.51
worker.tomcat2.type=ajp13

# Specify the size of the open connection cache.
#worker.tomcat2.cachesize

#
# Specifies the load balance factor when used with
# a load balancing worker.
# Note:
#  ----> lbfactor must be > 0
#  ----> Low lbfactor means less work done by the worker.
worker.tomcat2.lbfactor=100


# ------------------------
# Load Balancer worker
# ------------------------

#
# The loadbalancer (type lb) worker performs weighted round-robin
# load balancing with sticky sessions.
# Note:
#  ----> If a worker dies, the load balancer will check its state
#        once in a while. Until then all work is redirected to peer
#        worker.
worker.loadbalancer.type=lb
worker.loadbalancer.balanced_workers=tomcat1, tomcat2

#
# END workers.properties
#


---------------------------------------------------
Apache - httpd.conf:
---------------------------------------------------
LoadModule jk_module        libexec/mod_jk.so

JkWorkersFile conf/workers.properties
JkLogFile logs/mod_jk.log
JkLogLevel debug

AddModule mod_jk.c

JkMount /index.jsp loadbalancer
JkMount /bof/rp/* loadbalancer
JkMount /bof/jsp/* loadbalancer
JkMount /unittest-struts/* loadbalancer

---------------------------------------------------
My mod_jk.log
---------------------------------------------------

[Mon Apr 14 08:58:02 2003]  [jk_uri_worker_map.c (460)]: Into
jk_uri_worker_map_t::map_uri_to_worker
[Mon Apr 14 08:58:02 2003]  [jk_uri_worker_map.c (477)]: Attempting to map
URI
'/unittest-struts/unittest-struts/TestSessionCleanUpConversation/AddSessionA
ttributesActivity'
[Mon Apr 14 08:58:02 2003]  [jk_uri_worker_map.c (502)]:
jk_uri_worker_map_t::map_uri_to_worker, Found a context match loadbalancer
-> /unittest-struts/
[Mon Apr 14 08:58:02 2003]  [jk_worker.c (132)]: Into wc_get_worker_for_name
loadbalancer
[Mon Apr 14 08:58:02 2003]  [jk_worker.c (136)]: wc_get_worker_for_name,
done  found a worker
[Mon Apr 14 08:58:02 2003]  [jk_lb_worker.c (527)]: Into
jk_worker_t::get_endpoint
[Mon Apr 14 08:58:02 2003]  [jk_lb_worker.c (310)]: Into
jk_endpoint_t::service
[Mon Apr 14 08:58:02 2003]  [jk_ajp_common.c (1404)]: Into
jk_worker_t::get_endpoint
[Mon Apr 14 08:58:02 2003]  [jk_ajp_common.c (1448)]: In
jk_endpoint_t::ajp_get_endpoint, time elapsed since last request = 11
seconds
[Mon Apr 14 08:58:02 2003]  [jk_ajp_common.c (1116)]: Into
jk_endpoint_t::service
[Mon Apr 14 08:58:02 2003]  [jk_ajp_common.c (295)]: Into
ajp_marshal_into_msgb
[Mon Apr 14 08:58:02 2003]  [jk_ajp_common.c (432)]: ajp_marshal_into_msgb -
Done
[Mon Apr 14 08:58:02 2003]  [jk_ajp_common.c (642)]: sending to ajp13 #635
[Mon Apr 14 08:58:02 2003]  [jk_ajp_common.c (884)]: ajp_send_request 2:
request body to send 59 - request body to resend 0
[Mon Apr 14 08:58:02 2003]  [jk_ajp_common.c (642)]: sending to ajp13 #65
[Mon Apr 14 08:58:02 2003]  [jk_ajp_common.c (729)]: received from ajp13
#113
[Mon Apr 14 08:58:02 2003]  [jk_ajp_common.c (483)]: ajp_unmarshal_response:
status = 200
[Mon Apr 14 08:58:02 2003]  [jk_ajp_common.c (488)]: ajp_unmarshal_response:
Number of headers is = 2
[Mon Apr 14 08:58:02 2003]  [jk_ajp_common.c (532)]: ajp_unmarshal_response:
Header[0] [Content-Type] = [text/html;charset=ISO-8859-1]
[Mon Apr 14 08:58:02 2003]  [jk_ajp_common.c (532)]: ajp_unmarshal_response:
Header[1] [Set-Cookie] =
[JSESSIONID=B38B10E8EB04C7E6773848AEB86656FB;Path=/unittest-struts]
[Mon Apr 14 08:58:02 2003]  [jk_ajp_common.c (729)]: received from ajp13
#1028
[Mon Apr 14 08:58:02 2003]  [jk_ajp_common.c (729)]: received from ajp13
#141
[Mon Apr 14 08:58:02 2003]  [jk_ajp_common.c (729)]: received from ajp13 #2
[Mon Apr 14 08:58:02 2003]  [jk_ajp_common.c (1382)]: Into
jk_endpoint_t::done, recycling connection
[Mon Apr 14 08:58:02 2003]  [jk_lb_worker.c (389)]: Into jk_endpoint_t::done


Regards,

William Xu




---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Losing Session Affinity on Apache-Tomcat AJP13

Posted by Keith Brady <kb...@newbay.com>.
On Mon, 2003-04-14 at 15:06, Xu, William [CC] wrote:
> I configured one Apache and two Tomcat instances on a Solaris box. The load
> balancing seems to work well. However the session affinity is not. I am
> certain the JSESSIONID cookie is sent to the browser and sent back with
> every request. But AJP13 connector always round robin every request to the
> next server.  Could anybody help me figure out what the problem is? Thanks
> in advance. Here are my config file snippets:

I believe you have to add a unique jvmRoute to the <Engine> of each
backend tomcat server.

<Engine className="org.apache.catalina.core.StandardEngine" debug="0"
    defaultHost="localhost" jvmRoute="nbtc1"
    mapperClass="org.apache.catalina.core.StandardEngineMapper"
    name="Standalone">

I think it can be anything but it must be unique across all instances of
Tomcat participating in the cluster (I'm quoting from memory but it is
in the Tomcat docs for Engine I think).

You should see the jvmRoute being concatenated to the cookies.

cheers

-- 
Keith Brady
NewBay Software


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org