Thread Dump Skills are Very Important and Mandatory Skills in Today's J2EE Middleware world.
This skill help's us in identifying the Performances and Root causes of most of the Server/Infrastructure related issues. What we should aim to learn:
1)
Thread Dump overview & fundamentals understanding
2) Thread Dump generation techniques and available tools
2) Thread Dump generation techniques and available tools
3)
Thread Dump format Sun HotSpot
4)
Thread Stack Trace explanation and interpretation
5)
Thread Dump analysis and correlation techniques
6) Thread Dump common problem patterns (Thread race, deadlock, hanging IO calls,
garbage collection OutOfMemoryError problems, infinite looping etc.)
7)
Thread Dump examples via real life case studies
Before we jump in to the Internals of the Thread Dumps You need to understand the basics of the JVM environment
Java
VM overview
The JVM provides the middleware software and your Java / Java EE program with:
- A runtime environment for your Java / Java EE program (bytecode format)
- Several program features and utilities (IO facilities, data structure, Threads management, security, monitoring etc.)
- Dynamic memory allocation and management via the garbage collector
Your JVM can reside on many OS (Solaris, AIX, Windows etc.) and depending of your physical server specifications, you can install 1...n JVM processes per physical / virtual server.
JVM
and Weblogic interactions
This is showing you a typical and simple interaction diagram between the JVM, middleware and application. As you can see, the Threads allocation for a standard Java EE application are done mainly between the middleware kernel itself and JVM
Also, please note that certain Threads are managed internally within the JVM itself such as GC (garbage collection) Threads in order to handle concurrent garbage collections.
Since most of the Thread allocations are done by the Java EE container, it is important that you understand and recognize the Thread Stack Trace and identify it properly from the Thread Dump data. This will allow you to understand quickly the type of request that the Java EE container is attempting to execute.
From a Thread Dump analysis perspective, you will learn how to differentiate between the different Thread Pools found from the JVM and identify the request type.
Weblogic servers uses WorkManager for carrying
out/executing all the work internally
WLS
Work Managers Key Components
•
New Thread Pool Implementation: Single
internally managed thread pool and priority-based request queue service all
application requests
•
Request “Priority” dynamic and internally
computed to meet application-defined goals
•
Thread Count Self-Tuning
•
Self-tuning thread pool monitors overall
throughput every two sec
•
Present thread count, measured throughput, and
past history determines if thread count needs to change
•
New threads automatically added/removed as
needed
Benefits Administrators and Operators - no need to conduct tedious performance
testing or guesswork just to pick a static thread pool size that does not adapt
to changing workloads
Basics
of Thread States
A Thread can be in one of the following states:
- New
- Runnable
- Non-Runnable
- Sleep for a time duration
- Wait for a condition/event
- Blocked for a lock
- Dead
In a thread dump, we are looking at threads that have been created already and are either in running or non-running states. So, the new (unless a new thread just got created at the exact moment the thread dump was generated) & dead states are really not of value or present in a thread dump.
Running state implies the thread is actively working on something. Coming to the non-runnable states, its possible a thread has nothing to do and sleeps for some duration and periodically checks for condition to start work. Wait for a condition implies the thread is waiting for some form of notification or an event and can start work once there is a green light. Its much more efficient to use waiting for a condition pattern instead of regular sleep-wake up pattern for optimal usage of resources. If there are multiple threads regularly doing a sleep and wake up periodically, they can be optimized to wake up on notify of an event and only one thread would be successful in getting the notify call instead of all doing the regular check for event in the sleep pattern.
Blocked implies it cannot proceed with its work till it can obtain a lock which is currently held by someone else. This is similar to obtaining a lock to a Critical Region or Semaphore (in OS semantics) before proceeding with the work.
JVM Thread
Dump – what is it?
Thread
Dumps