Sizing a JVM for optimal performance is one of the trickiest tasks in the performance tuning for Java/JEE applications. While organizations have their own methodology to sizing a JVM, it is recommended to execute the JVM sizing in continuous phases with two distinct action steps. The sizing at the first step of tuning exercise is imperative to create a base. However, when performance issues are uncovered and fixed through code changes then it is suggested to size the JVM again for optimal performance. The rule of thumb I follow is to tune or size the JVM whenever there are changes to the code. Mentioned below are general tasks when sizing a JVM:
- Run short duration tests such as for example, 10 minutes or 20 minutes. This time duration depends on the length of your business transactions that you plan to stress test.
- During these short duration tests determine and tune the JVM parameters of interest such as setting of maximum and minimum sizes for heap, GC algorithm among others.
- Note that the max/min sizes of heap is determined based on multiple factors for example, the number of objects created in a transaction path, memory consumed by these objects that are still alive (i.e. have a reference) among others.
- Note the application response time and JVM behavior (for example the number and duration of minor and major garbage collections, heap growth) and apply the one that best balances JVM behavior with optimal application response time defined in your SLA.
- Run long durations tests. The duration of such tests is usually constrained by your stress test environment availability. For example, if the application you are stress testing interacts with ten different legacy systems that can be available for a stress test in six hour intervals. Then you might want to run multiple two hour long duration tests and then possibly some six hour duration tests depending on the need. Fine tuning of the JVM can be done from such long duration tests.
Other articles of possible interest:
Top five Java application performance management tools
To scale out or not using Gigaspaces
AdventNet, one product for all performance/service management needs
Keynote and SOASTA, cloud offerings to test your web site performance
Three tools to monitor your Websphere MQ environment
Top six performance tuning tips for a Java enterprise application