Link to home
Create AccountLog in
Avatar of Kent Dyer
Kent DyerFlag for United States of America

asked on

Apache Tomcat Stickyness issue

Working with Apache Tomcat Windows 6.0.35, under 64-bit..  Windows 2008.
Seeing kind of an odd issue with Stickyness..
If we have the log4j.properties in DEBUG mode, connections are not released
If we have the log4j.properties in INFO mode, connections are released

We are doing a rollout and go-live with a customer and would like to keep the server in DEBUG as much as possible.  Can we use DEBUG with stickyness turned off?

Thanks,

Kent
Avatar of mrcoffee365
mrcoffee365
Flag of United States of America image

Of course you can use log4j with DEBUG whether sticky is turned on or off.  Something else must be going on.  Are you really restarting all the Tomcat instances after changing the log4j properties file?  It sounds as if it isn't being reloaded by some of the instances.
Avatar of dpearson
dpearson

If I had to guess, I would think this could be caused by some of your DEBUG logging throwing exceptions inside the logging code, e.g.

if (logger.isDebugEnabled()) logger.debug("Time to dump out my object details " + root.element) ;

will throw a null pointer exception if root is null - but ONLY if logging is set to DEBUG.  

Then that exception could cause your connections to not be released etc.

At INFO level this code never executes and there's no exception.

Doug

P.S. Of course in general you can run in DEBUG logging in production and it should have no impact on your behavior except a very slight reduction in performance (writing log files is very fast as the writes are all sequential and easily buffered).  It certainly shouldn't cause connections to remain open - that's due to some bug.
Avatar of Kent Dyer

ASKER

We really want to use independent instances of tomcat and let the F5 LB handle the traffic..

Below is a link that I did find which appears to be noteworthy especially with the settings on the appliance.  Of course, the article has information about setting up Apache as the Clustering component.  But, again it causes question in my mind if you want to pull a node out of the triad to do maintenance, how does the LoadBalancer or rather Tomcat know that it is part of the cluster unless you configure the software in this manner.  Right now, "never the twain shall meet,"  I still think in terms of like how Citrix does LoadBalancing (traffic cop) scenario.

As we are looking at the configuration/cluster setup..  I think this page becomes more important..

http://tomcat.apache.org/tomcat-6.0-doc/cluster-howto.html

There is information about Multicast, Stickyness, etc. and I think this is critically important that not only we follow this, but the networking team does for the sticky session mode as well.

>>
Cluster Basics
To run session replication in your Tomcat 6.0 container, the following steps should be completed:
•      All your session attributes must implement java.io.Serializable
•      Uncomment the Cluster element in server.xml
•      If you have defined custom cluster valves, make sure you have the ReplicationValve defined as well under the Cluster element in server.xml
•      If your Tomcat instances are running on the same machine, make sure the tcpListenPort attribute is unique for each instance, in most cases Tomcat is smart enough to resolve this on it's own by autodetecting available ports in the range 4000-4100
•      Make sure your web.xml has the <distributable/> element
•      If you are using mod_jk, make sure that jvmRoute attribute is set at your Engine <Engine name="Catalina" jvmRoute="node01" > and that the jvmRoute attribute value matches your worker name in workers.properties
•      Make sure that all nodes have the same time and sync with NTP service!
•      Make sure that your loadbalancer is configured for sticky session mode.
Load balancing can be achieved through many techniques, as seen in the Load Balancing chapter.
>>

Thanks,

Kent
ASKER CERTIFIED SOLUTION
Avatar of dpearson
dpearson

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account