October 18, 2010 by
Category:

One of the tools available for improving performance of Java applications is application profiling.  This involves using a tool to gather detailed information about how an application executes to look for various ways to improve performance.

Although profiling information is often done by developers it can also be done by administrators using tools in the IBM Support Assistant.  These tools are free, easy to install, and can help gather information to indicate there may be problems to pass along to developers to fix.  Also, developers who do not use Rational Application Developer, which also has built-in profiling tools, could use the free tools in IBM Support Assistant.

The primary tool we will describe here is the “Health Center” tool for IBM JVMs.  Note that the instructions here would be valid for Windows and other operating systems may be slightly different but this article provides links to resources for all operating systems.

Install Profiling Tools to IBM Support Assistant

The first step would be to install the IBM Support Assistant (ISA) Workbench if you have not already installed it.  The main tool we will show requires the 4.1 version of the ISA Workbench so if you have a previous version it is usually best to uninstall and then reinstall 4.1.

Once you have the ISA Workbench installed open the program.  If this is the first time you have run the ISA Workbench it will often start a “First Steps” wizard to provide links to open the network and updating preferences, two important settings that you may need to configure to allow the ISA Workbench to connect to IBM servers through a firewall.  If you do not see this wizard but you know you need to set preferences you can also go to the File –> Preferences menu item.

If you use the First Steps wizard it will usually launch a tool to update the “add-ons” installed with ISA.  If this tool does not launch you can select Update –> Find New.. –> Tools Add-ons.  The updating tool may not appear immediately and you may see a progress indicator in the lower right corner.

image

image

When the tool add-ons are shown there may be different categories depending on the software you have chosen to support with ISA.  You will almost always have a ‘JVM-based Tools’ category though as many IBM products use Java.  Expand this category and check the IBM Monitoring and Diagnostic Tools for Java – Health Center option.  Unlike the screenshot below you may see several tools with similar names so make sure you choose the ‘”Health Center” as that is the tool we will highlight here.

image

Once the proper tool is selected press the Next button, accept the license and press the Next button again, and then press the Finish button to begin installing the tool.  You may not notice anything is happening except a progress indicator in the lower right corner.  Wait for the installation to complete.  Once the installation is complete you will be prompted to restart the ISA Workbench.  Click Yes to allow the restart.

Health Center Tool Architecture

The architecture of the Health Center tool is to run an “agent” within the Java JVM of the application you wish to monitor.  You will then connect to this agent from the tool run from the ISA Workbench.  If the application you are monitoring is on a different system than the ISA Workbench you will need to make sure to connect to it through firewalls and use the hostname of the machine running the application being monitored when connecting from the tool.

Since you will be installing the agent software and connecting to a live environment it is likely that you may not use the Health Center with production systems.  There are other tools that may be used with the ISA Workbench that would not require an agent to connect from another tool or would not require installing any software that is not already part of normal fixpacks since both of these procedures might violate change management policies on production systems.

In general though the kind of information you are looking for with the Health Center will be better to collect early in the deployment cycle so it may be better to use the Health Center with test and QA systems anyway which may not have quite the same policies against running the Health Center agent.

image

Launch Health Center Tool

To launch the Health Center tool click on the “Analyze Problem” shortcut on the main Welcome page of the ISA Workbench.

image

You can also get here by clicking the Launch Activity button and selecting Analyze Problem.

image

If the list of installed tools is not displayed, click the Tools tab along the top to display the list.

From the list of tools select the IBM Monitoring and Diagnostic Tools for Java – Health Center.  Remember you may have different tools than shown below.

image

Once the proper tool is selected click the Launch button in the lower left.

Leave the first page of the Connection Wizard open for the next section.

image

Install Health Center Agent

The Health Center agent is packaged as a Zip file that you extract to your Java JRE of the environment you want to use the Health Center with.  The best way to get the correct package is from the help topics of the Health Center ISA add-on.  The steps in this section will only need to be done once.

To do this click the “Enabling an application for monitoring” link from the first page of the Connection Wizard shown above.  The ISA Workbench help will open.

On the first page that appears click the link for “installing the Health Center agent” in the prerequisite section.

image

On the page that appears click on the link for the operating system you will be running the agent on.  This may be different than the operating system you are using for the ISA Workbench.  The files listed are packaged with the tool.

image

Save the Zip file to the machine you will be running the agent on.  Save it to the directory above the root of the Java Runtime Environment, or JRE.  For example on WebSphere Application Server the JRE is usually at <WAS_ROOT>/java/jre so you would save the Zip file to <WAS_ROOT>/java.

Unzip the Zip file to the folder above the JRE root directory, making sure to preserve the folders contained in the zip file.  As shown below this zip file will extract different files, the most notable the healthcenter.jar file, into different locations in the JRE.  Depending on your fixpack of the IBM JVM you may be replacing some Health Center files already present but this is OK as it is best to use the files provided with the version of the Health Center you are using.

image

Double check that the following file is present to make sure files were extracted properly:

<JRE_ROOT>/lib/ext/healthcenter.jar

Enable Health Center Agent

The steps for enabling the Health Center agent differ depending on what type of Java application you are using the agent with.  There instructions will show using WebSphere Application Server v7.0 which uses Java 6.0.

Since we are using WebSphere Application Server you want to expand the ‘Configuring WebSphere or Rational product environments’ and select the ‘Configuring WebSphere Application Server environments’ topic.

image

Start the WebSphere Application Server using the normal method.

Login to the Administrative Console.

Go to the server properties by selecting ‘Servers –> Server Types –> WebSphere application servers’ in the Admin Console navigation and clicking the name of the server.

Expand ‘Java and Process Management’ and click the ‘Process Definition’ link.

Click on the ‘Java Virtual Machine’ link and find the setting for ‘Generic JVM arguments’.

The next step is highly dependent on the Operating System and version of Java (including fixpacks) so check the Health Center help for the correct values.

For the ‘Generic JVM arguments’ we will use the following since we are using Windows and Java 6 with no fixpack:

-agentlib:healthcenter -Xtrace:output=C:\temp\perfmon.%p.out

(This assumes you already have a C:\temp directory, create one if you don’t as the setting above indicates where the agent will store data)

image

Double check the value you enter because an incorrect JVM argument can prevent the server from starting.  If you are using a “standalone” server that performs it’s own administration you might even need to manually edit the server.xml file if there are problems.

Click the OK button at the bottom of the page and then save the changes to the configuration.

Restart the server to use the new settings.

Connect from Health Center

Once your server is started with the proper settings you can return to the Health Center tool and connect.

Close the ISA Workbench help if it is still open.

Return to the Health Center connection wizard.  You can select File –> New Connection… with the Health Center tool active if you closed it.

If you are connecting to the server running on the same machine you can use ‘localhost’, otherwise enter the host information.  We are also using the default port although you can change this in the <JRE_ROOT>/lib/healthcenter.properties file you extracted with the agent installation.  In this case we are also not using authentication from the Health Center.  It is possible to enable this by following steps in the Health Center help topics.

image

Once your settings are appropriate for your setup click the Next button and the tool will search for connections.

Once a valid connection is found select it and press the Finish button.

image

The Health Center tool will begin collecting data.  Give it a minute to “catch up”, especially if you just restarted the server.

image

Using the Health Center Tool

Note: Although this section will give you a brief overview of some of the things you can use the tool for the Help topics have much more detail and great references for more information about certain kinds of problems.

The first thing you might want to do, especially if you are looking at an application running on a server that just restarted is to clear the data from when the server was starting.  This way you will not be including the garbage collection and other data from that time period.  You can clear the data previously collected by selecting Data –> Reset Data in the menu or using the corresponding button.

The Status view of the tool, which is the first page shown when you connect, will provide links to show the other perspectives and messages about certain types of problems that may be occurring.  Unless you are investigating a specific problem one of the best ways to use the tool is to run a load test of a deployed application and look if there are any messages in the Status view of potential problems.  If there are messages about problems you can click the link for the view that will help you investigate further.

image

The “Garbage Collection” perspective shows memory statistics and can do some analysis of memory problems.  Although it does not seem able to directly detect a “memory leak” you can get a live picture of the state of the memory heap size and look for the symptom of a memory leak where the memory keeps increasing.  You can then use other tools of the ISA Workbench to specifically investigate a memory leak problem.

image

The “Locking” perspective shows how much application code is waiting for locks between synchronized blocks of code.  This graph is a little tough to interpret because the height of the bars is always the “slow” value for the lock monitor.  Even if you sort the list below by something else the height of the bar will stay the same.  The bars will be colored red or yellow if a lock has a high “% miss”.  This is one of the primary things to look for as it indicates one thread is trying to get a lock while it is help by another thread and results in blocking.

image

The “Profiling” perspective lets you see how much time executing particular methods took.  You generally want to sort by the “Self” value to show the methods which took the highest time without the other methods it called included.  You can also sort by “Tree” but you have to remember that in a server application many things will be threads just waiting to execute or handle asynchronous I/O.  If you do sort by “Tree” make sure to scroll down and find the methods that are part of the application and not necessarily methods running WebSphere code (com.ibm…).

image

There are a few other perspectives and types of data available from the Health Center but these are generally the most useful to help diagnose the most common kinds of application problems.

One thing to keep in mind when using the Health Center is that the data is collected incrementally and meant more to show longer terms trends so it might be several seconds or a minute before you see what has been happening in the application due to recent activity.  One thing you can do is to select File –> Save Data to save the data from particular tests to analyze after the test has been performed.

Summary

Hopefully you can see that the Health Center tool available from the IBM Support Assistant Workbench is a tool that can help you quickly start diagnosing common application performance problems.  Based on the data from this tool you can use other tools provided with ISA to dig deeper into specific problems and provide developers or administrators information they can use to help resolve these issues.

11 Comments

Ma'en

Great article, simple and straightforward.
I tried it and it worked perfectly and saved my time
Thanks for the excellent efforts, appreciated

Ryan Clemson

Thanks for the great tutorial Stuart. Followed your instructions and got Health Center up and running!!! Much appreciated!

Michael Sobczak

Thank you for writing this. Much clearer than the instructions provided by IBM!

phu tran

Hi Stuart

I tried to make a new connection without successfully. I am getting ‘No JVM detected on localhost in port range 1972 to 2072’. I have spent a fair bit of time on this but could not found any solutions.
Can you please help !

Much appreciated.

Thanks in advance
Phu

phu tran

Hi again Stuart
I’ve resolved my problem previously mentioned.
The solution is I have manually modify the ‘Generic JVM arguments’, I cannot do this via the admin console.
My application can now connect with the Health center agent.
Thanks for your article, I found it very useful.
Phu

phu tran

Hi again Stuart
I’ve resolved my problem previously mentioned.
The solution is I have manually modify the ‘Generic JVM arguments’, I cannot do this via the admin console.
My application can now connect with the Health center agent.
Thanks for your article, I found it very useful.
Phu

Vijayanand

hi,
I have did it as you said in this blog. But I dont see Method profiling and IO enabled. can you please help me how to get these things fixed.

Stuart Smith

The current versions of the tools might be slightly different than mentioned in this article. Do you see a connection to the JVM from the tools? Are there other things that appear to be working?
I think my question is if this is really something that is not working or just a little different than the article describes.

Tim

Would there be a noticeable performance hit to getting this running on a production server? If so, any idea of how much? I got this running on our test server – it works great with all kinds of useful information. I’d love to have it running at least for a short time on prod but I’m concerned it may slow our production environment.

Let me know what you think. Thank you.

Tim.

Stuart Smith

There probably would be some overhead but I’m not sure how much. I did poke around and according to the following links it is “suitable for production use” depending on the version of Java you use. WebSphere 6.0 and earlier the answer is no, WebSphere 8.0 and later it looks OK, and WebSphere 6.1 and 7.0 it will probably depend on the fixpack of the Java environment you have.

https://www.ibm.com/developerworks/mydeveloperworks/blogs/kevgrig/entry/running_ibm_java_healthcenter_in_headless_mode48?lang=en
http://publib.boulder.ibm.com/infocenter/hctool/v1r0/index.jsp?topic=/com.ibm.java.diagnostics.healthcenter.doc/topics/platforms.html

One thing you could also do is create an “access log” to track what web requests come in and then create a stress test in another environment that replicates the type of usage you see in production and make some decisions from that.

Another idea to try first might be to enable verbose garbage collection on the server and then use tools from the IBM Support Assistant to analyze the output. Verbose garbage collection can give you similar memory info and let you work on tuning the memory settings which is often one of the primary things that can be done to improve performance.

Generally the goal of “profiling” is to get some more info about how long it takes to execute specific paths in the code to see where effort could be spent to make the code execution more “efficient”. This helps provide some focus in doing this since you want to focus on the code that is least efficient and is ALSO executed fairly often. Trying to “optimize” everything is not the best approach.

Comments are closed.