There is no way to completely answer this question in a few words or paragraphs. Performance tuning is one of the more complicated tasks, especially if you have limited expertise. When I have to deal with the performance tuning I am following the systematic approach.
First, find the parts of the application that require improvement, whether they’ve been discovered during the development cycle, functional testing or reported by the application users in production. No reason to take on everything as you will complete nothing.
Depending on the system - the real issue can lay in hardware, network, system architecture, custom code, or combination of things, etc.
Without proper approach - you can spend weeks, months without success. And try to add heavy user load scenarios to the mix and this will multiply the complexity.
Second - define what tools you will use to identify the issue. You can decide to analyze JVM first, or use known java profilers, or use java monitoring and analytical tools.
I personally like to have a big picture first and then be able to drilldown to the lowest possible level. There are a few tools available on the market to help you with that. I recently used Discovered Byte analyzer with good results (and it is free). You can get it from http://discoveredbyte.com
. What I like about it? It will highlight and give you quick view of the system or specific issue that you are dealing with in pre-analyzed report. I see it as big picture of the issue(s).
When I have that - If I see that server utilization is constantly maxing, then it is limitation on the hardware side (unless you have memory leaks or inefficient code that eats up CPU. Unfortunately you can’t check memory leaks with the Discovered Byte analyzer, but you can see CPU usage by heavy methods, and for me it is very important.)
If I see heavy methods or pages - I drill down to the method. I like to use filters and control level of the execution to display heaviest methods that contributed to the bad performance results.
The lowest hanging fruit is bad queries - you can view them as well, but in reality - you are lucky if it is just SQL issue. I recently dealt with repeated SQLs - single query was executed in just a few milliseconds, but was ran many thousands times from the single method! (That was fun to catch?)
Third - once you have the data you can make a decision on how to fix it. HW or custom code – the easiest ones; architectural flows or vendor code usually take longer time to address.