How to diagnose Performance problems in Java Web Applications?

Problem Statement

Your Java/J2EE Application is performing sub-optimally.


  • Slow (Web Page) Response Times, always or sometimes.
  • High Memory Usage / Out-Of-Memory Errors
  • Application stalls (stops responding)
  • High CPU Utilization


Step 1: Analyze Key Performance Parameters

  • Enable JMX on the Application Server. Here is how you can do this.
  • Now, use a tool like Java Visual VM, to view these Performance Parameters: CPU, Memory, Thread Usage
  • This should tell you: if any of these resources(CPU/Memory/Threads) are heavily used
  • Look for CPU Utilization graph” for any unusually high Garbage Collection.

Step 2: Analyze Thread Stack Dump

  • Here is how you do this.
  • This should tell you what your threads were doing when Thread Stack Dump was taken.
  • You may want to take Thread Stack Dump multiple times to look for potential problems.
  • If a very large number of Threads are in BLOCKED state, it is a sure sign of problem, the stack trace tells you what the Thread is blocked on. For example if there is a problem with Logging, it is seen that over a period of time All Threads get Blocked on Logging activity, and in therefore stalling the application.

Step 3: Analyze Heap Memory

  • Take a Heap Dump( say by using jmap) and Analyze it (in tools like jhat). Here is how you do this.
  • This should tell you what is using up your memory.
  • Things to look for: Instance Counts (of Classes), Size of all Instances (of a Class).

Step 4: Analyze Business Transactions

  • TODO: Here is how you do this.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: