Solved

Apache Tomcat Stickyness issue

Posted on 2013-01-06
5
725 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 27

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 27

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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
PHP Apache application gives "Forbidden" message 5 55
simple java question 3 55
Error trying to install RTMT Win7 5 59
type mismatch (Object[] to double[] 4 23
Convert websphere application server default chained Certificates from 1024 to 2048 keysize or higher size and also you can change signatureAlgorithm . Please make sure Websphere Application Server fixpack 7.0.0.23 or Above. The following steps a…
If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

813 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

13 Experts available now in Live!

Get 1:1 Help Now