Application side statistics analysis

From application side analysis we have monitor code level issues like threads, classes , packages and memory leakages etc.....
To monitor the code level issues we may use jconsole,JVM ,JMC ,dynatrace and appdynamics .


JVisualVM:
JVisualVM is a default profiling tool for JVM. To leverage the services we have to install JDK.
Steps to invoke JVisualVM:
 My Computer
 Program Files
 Java
 bin
 JVisualVM

We can Monitor
1. Local Machine
2. Remote Machine
Steps to invoke Remote Machine:
 Go to Remote tab
 Add ProcessID
 Add JMX connections by providing Port Numbers

1. Overview:
Here we can view how much memory?, XMS & XMX settins, JVM version, JRE VersionHere we can check JVM Arguments & System Properties

2. Monitor:
By default we can View CPU,Memory,Classes,threds graphs
Here we can perform GC and we take heap dump .Heap dump extension is “.hprof”
Here we can check memory leakge with the help of heap metaspace graph.

3. Threads:
Here we can view thread status like Running(), Sleep(), Park(), Waiting()
And we can take thread dump for Analysis Purpose.
Note 1: For thread dump analysis copy the thread dump and paste it in any online thread analyzer tool.
Note 2: We can’t copy Thread dump from remote machine to local machine and vice versa.

4. Sampler:
Here we can view how much CPU & Memory Utilized by each & every thread as part of JVisualVM

Thread Dump:
Whenever application is not performing well, we used to analyze thread dump.
Thread Dump is a snapshot of thread status.

There are two types of threads:
1. Demon Threads: Which are invoked by OS and hardware level
2. Non Demon Threads: Which are created by program.

Thread contention:
Thread contention is a status in which one thread is waiting for a lock which is locked by some other thread.

Deadlock:
Deadlock is a situation where one or more threads are waiting for other resources which are locked by some other threads.

Thread synchronization:
This code will allow the threads to use multiple resources by multiple threads.
In Java, every object has one monitor. At any point of time, only one thread get lock on monitor. Other threads will wait until monitor will be released.
Note: Thread dumps will be published with the help of jstack or jvisualvm.
As part of analysis, we are going to identify which threads are in blocked status and waiting status.
If you find any blocked threads, verify for which stack it is looking for, who locked on expected stack, copy these details and post to developer.
If you find waiting threads, we have to find which methods are executing for particular thread (wait (), park (), sleep ()) and copy details and post to developer.

If multiple threads are trying to get locks on stacks which is locked by some other threads causes deadlock threads. Apart from above analysis, we do have internal thread analyzer tools.
Using these tools, we are deducting the deadlocks and thread level issues. For infrastructure level, we have to take CPU sampling, which thread is utilizing more CPU and report the same.


Memory Dump:
Memory dump is a snapshot of memory utilization statistics in a particular time period.
Whenever you received OOM (Out of memory) exception or memory leakages we have to take
the memory dump to find out the root cause.

We do have two types of memories
1. Stack memory: Static variables will be loaded into stack memory
2. Heap memory: Dynamic variables will be loaded into heap memory.
Memory dump contains below information:
 Objects
 Classes
 Class Names
 Class loader information
 Fields
 Primitive fields
 Garbage collection roots
 Thread level data
 Stacks
To understand the memory dump, we should drill down how many threads required for our application, how much memory required by each and every thread will give detailed idea about memory footprint (static)
Memory dump will give static memory and dynamic memory information (user session) for analysis purpose.
Using memory dump, we can identify which object, class are running for more time, we can copy them and send to the developer.
If you are not able to analyze the memory dump manually, we can use memory dump analyzertools to identify the issue.
Memory dump extension is “.phd” or “.hprof”

Note: Using Dynatrace we can drilled exact place which causing for delay in response times.
But for dynatrace license is required. 

No comments:

Post a Comment