Solved

Apache Tomcat Stickyness issue

Posted on 2013-01-06
5
721 Views
Last Modified: 2013-01-10
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
0
Comment
Question by:Kent Dyer
  • 2
  • 2
5 Comments
 
LVL 26

Expert Comment

by:mrcoffee365
ID: 38753334
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.
0
 
LVL 26

Expert Comment

by:dpearson
ID: 38753709
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.
0
 
LVL 17

Author Comment

by:Kent Dyer
ID: 38757748
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
0
 
LVL 26

Accepted Solution

by:
dpearson earned 250 total points
ID: 38757781
Session stickiness is a different thing than connections that aren't being closed.

Session stickiness (which that link relates to and your F5 load balancer is talking about) is whether you send a second request to the same server or not.  If you enable "stickiness" then life is simpler for the application developer as they can store local information within their tomcat instance and subsequent requests will go to the same server and retrieve that information.  The downside is that load balancing needs to be smarter - it can't just send each request it receives to the least loaded server - it needs to know which session they are part of.

However, the problem you descibed - having connections that don't terminate - suggests a situation where you are holding the connection open - e.g. by failing to send any response to a request.

Neither *should* have anything to do with the logging level, but it looks like you have a bug in the application that's running on Tomcat causing it to keep the connection open (*not* the session - that's a different thing) and someone needs to find and fix that bug.

Doug
0
 
LVL 26

Assisted Solution

by:mrcoffee365
mrcoffee365 earned 250 total points
ID: 38757782
You should ask a different question if you want to discuss load balancing and Tomcat.  We answered the log4j question.  

If you have more information about how your app is failing in a bad log4j call or in not restarting the instance after changing the log4j configuration, then that could go here.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
json example 39 115
wordappend challenge 8 86
solarwind tftp server 2 32
Securing Jmx Console and web console 2 48
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now