?
Solved

Apache Tomcat Stickyness issue

Posted on 2013-01-06
5
Medium Priority
?
733 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 28

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 28

Accepted Solution

by:
dpearson earned 1000 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 1000 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
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 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:
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses
Course of the Month14 days, 8 hours left to enroll

770 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