/ Java EE Support Patterns: Stuck Thread Patterns
Showing posts with label Stuck Thread Patterns. Show all posts
Showing posts with label Stuck Thread Patterns. Show all posts

8.18.2011

Stuck Thread how to resolve part 1

In my Java EE production support experience, stuck threads is by far the most common production problem you will face in your day to day work. Some of these problems are straightforward while others are very complex to pinpoint. This issue is quite common, regardless of the Java EE server that you use (Weblogic, WAS, JBoss etc.).

This article is the part #1 of a series of articles which I will share with you my knowledge on stuck Thread related problems; including root cause analysis, which tools to use, how to take corrective actions and how to prevent stuck Threads at the first place. So please come back regularly for more updates on this topic.

For now, let’s start with the basics and understanding of Thread Pools in the Java EE container world.

Java EE container and Thread Pools

Thread Pools are part of the foundation of your Java EE container. Every new request that comes in to your application server will at some point require a Java Thread allocation in order to execute its task. Executing each request in its own separate Java Thread provides the container with multi Thread and concurrent processing capabilities.

Find below a simple diagram showing you an example of 2 concurrent HTTP requests reaching a Weblogic 11g server:

Why are Threads getting stuck?

As you can see from the diagram, the Threads are executing the actual allocated request from the Weblogic Kernel. Most of the problems happen when the Thread execution is reaching the application or business layer.

At this point your application Java code modules will be performing a lot of business logics, including sending and receiving data from external sources such as a Web Service or an Oracle database for example. Any problem with such external system will cause the Thread to hang and wait for data to come back.

Other situations can occur such as internal deadlock, infinite looping, heavy IO contention on your server etc.


What can you do about it?

Please note that I'm currently working on a Thread Dump analysis training plan available from this Blog. I highly recommend that you read it; I'm confident that it will greatly improve your Thread Dump analysis skills and help you prevent and resolve stuck Thread problems.

Finally, please feel free to submit your Thread Dump data to the Root Cause Analysis Forum or via my email address @[email protected] and I will analyze it for you.