The Support Authority: Know what your Web application is really doing

Using the IBM Monitoring and Diagnostic Tools for Java - Health Center

The IBM® Monitoring and Diagnostic Tools for Java™ - Health Center is a lightweight tool that monitors IBM virtual machines for Java with minimal performance overhead. It provides live information and recommendations about classes being loaded, the virtual machine environment, garbage collection, locking, and profiling. This article introduces you to the Health Center and shows an example of how it can be used to check the impact of a source code change in a Web application. This content is part of the IBM WebSphere Developer Technical Journal.

Dr. Holly Cummins, Software Engineer, IBM

Holly Cummins is a performance-tooling developer within the IBM Java Technology Centre. She leads development on IBM Monitoring and Diagnostic Tools for Java - Health Center and was the author of the GC and Memory Visualizer tool. Her tooling work builds on her experience working as a performance engineer within the garbage-collection development team.



Helen Beeken (hawkinsh@uk.ibm.com), Software Engineer, IBM

Dr. Helen Beeken is a software engineer developing RAS tooling at the IBM Java Technology Centre. Before joining the team, she worked on the open source AspectJ and AJDT Eclipse projects and helped to stress-test large software systems.



Toby Corbin, Software Engineer, IBM  

Toby Corbin is a software engineer currently developing RAS tooling within the IBM Java Technology Centre. He joined IBM in 2001 and spent four years developing national language support and globalization of the Java Runtime Environment, followed by two years developing the Swing and AWT libraries.



Russell Wright (rbwright@us.ibm.com), WebSphere Serviceability Development, IBM

Russell Wright has several years of experience developing and supporting data communications and middleware software including WebSphere Application Server. He currently manages the deployment of troubleshooting tools for the IBM Support Assistant and is a developer for the IBM Guided Activity Assistant.


developerWorks Contributing author
        level

04 November 2009

Also available in Chinese Russian

In each column, The Support Authority discusses resources, tools, and other elements of IBM® Technical Support that are available for WebSphere® products, plus techniques and new ideas that can further enhance your IBM support experience.

This just in...

As always, we begin with some new items of interest for the WebSphere community at large:

  • Are you ready for IMPACT 2010? Register early and save on registration fees and hotel accommodations. IMPACT 2010 is the premier conference for business and IT leaders. Join us in Las Vegas, May 2 through 7, and learn to work smarter from the most experienced business and technology leaders in the world.
  • Check out these new and updated tools for the IBM Support Assistant: See the Tools Add-ons List for a complete list of diagnostic tools available for the IBM Support Assistant.
  • Have you tried the IBM Support Portal yet? If not, this is a good time to start using it, because the current IBM software support pages will be replaced by IBM Support Portal in January 2010. All IBM software products are now included in the IBM Support Portal. See the Support Authority's Introduction to the new IBM Support Portal for details. Be sure to let us know what you think by sending your comments and suggestions to spe@us.ibm.com.
  • New! Now you can use My Notifications to stay informed of available fixes. Follow these steps to update your subscriptions:
    • Click My Notifications to manage your subscriptions.
    • Select a product family (for example, WebSphere).
    • Check one or more products and click Continue.
    • Check Fixes under Document Types and click Submit.
    And that’s it! You will now receive notifications whenever there are fixes available for your selected products.
  • The Global User Community at websphereusergroup.org continues to grow! Check out these two new virtual user groups where you can collaborate with other “WebSpherians” from around the world:
  • Do you use business process management (BPM) products? If so, check out the announcement for BPM V7.0.
  • There are several exciting webcasts planned in November at the WebSphere Technical Exchange. Check the site for details and become a fan on Facebook!

Continue to monitor the various support-related Web sites, as well as this column, for news about other tools as we encounter them.

And now, on to our main topic...


Introduction

IBM Monitoring and Diagnostic Tools for Java - Health Center is a new addition to IBM’s portfolio of Java diagnostic tools. This tool provides an integrated solution for detecting and diagnosing performance, capacity, and stability issues in Java applications.

Health Center can monitor any application running on an IBM Java Virtual Machine (JVM), including IBM WebSphere Application Server ) and related WebSphere products. It supports a full range of platforms including z/OS®, AIX®, Linux®, and Windows®.

Health Center collects comprehensive method profiles with an extremely low overhead, highlights contended locks, analyzes garbage collection and heap usage, and visualizes class loading activity. It also checks for command line options that could cause stability or performance problems. Health Center provides visualizations, analysis, and recommendations, which you can see in the Status view (Figure 1), displaying an overall view of the Health Center’s findings.

Figure 1. Status view
Figure 1. Status view

If you use WebSphere Application Server’s Performance Monitoring Infrastructure (PMI) for performance tuning, you will find that some of the same information (like heap usage) is available through both PMI and Health Center. However, there are important differences to be aware of that will help you determine when to use each tool.

The Health Center is different from PMI in that it is Java-focused and so it does not include higher level or Web application-specific metrics, such as HTTP response times and servlet request counts. Instead, it provides very detailed Java information, much of which is unavailable elsewhere. It also includes method profiles, which are extremely helpful in identifying poorly performing code or code that is being unnecessarily called. Health Center also features lock analysis for identifying synchronization bottlenecks, and a garbage collection perspective, which can spot when garbage collection is causing application slowdowns.


Installing Health Center

The Health Center agent requires a minimum Java level of 1.5 SR8 or 1.6 SR2. IBM WebSphere Application Server V7.0 ships with a version of Java that supports Health Center by default; WebSphere Application Server V6.1 must be updated with an SDK fix pack to at least Java 1.5 SR8.

Before you can use the Health Center you must set up your system for monitoring:

  1. Install the Health Center agent and client.
  2. Configure WebSphere Application Server to enable monitoring.
  3. Connect the Health Center client to a Java application.

The Health Center tool has two parts:

  • An agent that sends information from the monitored JVM to the client.
  • A client that connects to the agent and shows information about the health of the Java application.

Before an application can be monitored, the Health Center agent must be installed into the JVM it uses, and the application must be started with special command line options. JVM versions 1.5 SR9, 1.6 SR3, and newer ship with an agent by default. Prior JVMs can be upgraded using an agent available from within the client.

The Health Center client is a tool add-on for the IBM Support Assistant. Follow the instructions for how to install and run tools for the IBM Support Assistant to install the client. Select IBM Monitoring and Diagnostic Tools for Java – Health Center when asked to install or launch a tool.

After the client is installed, you can download the agent from within the client and install it into the JVM you wish to monitor. Even if you’re using the JVM that is shipped with the Health Center agent, be sure to pick up the latest agent because it will contain the latest updates and defect fixes. To do this, click the Enabling an application for monitoring link on the first page of the connection wizard (Figure 2). The IBM Support Assistant help system opens to a page that contains links to the downloadable Health Center agents (Figure 3).

Figure 2. Health Center connection wizard
Figure 2. Health Center connection wizard
Figure 3. Health Center agents
Figure 3. Health Center agents

Download the appropriate agent for your platform and unzip the agent into the root directory of the target JVM. For example, in a typical Linux environment, unzip the agent into /opt/ibm/WebSphere/AppServer/java.


Configure WebSphere Application Server to enable monitoring

To enable WebSphere Application Server and your applications for Health Center monitoring, use the administrative console to adjust the JVM configuration:

  1. Start the administrative console.
  2. Select Servers => Application Servers.
  3. Choose the server you want to monitor.
  4. Scroll down to Sever Infrastructure (Figure 4).
    Figure 4. Administrative console: Server Infrastructure
    Figure 4. Administrative console: Server Infrastructure
  5. Expand Java and Process Management.
  6. Click Process Definition.
  7. On the new page that opens, go to Additional Properties and click Java Virtual Machine (Figure 5).
    Figure 5. Administrative console: Additional Properties
    Figure 5. Administrative console: Additional Properties
  8. Scroll down to the Generic JVM arguments field, and add these arguments (Figure 6):
    -agentlib:healthcenter -Xtrace:output=perfmon.%p.out
    Figure 6. Add arguments to the JVM Arguments field
    Figure 6. Add arguments to the JVM Arguments field
  9. Save your settings and restart the application server.

The Health Center agent will try to listen on port 1972 and auto-increment if that port is in use. If there is a firewall between the Health Center client and agent, make sure that the agent’s listening port is open.


Configure your development environment to enable monitoring

After you have installed a Health Center agent and updated your WebSphere Application Server configuration, you're ready to start monitoring. To monitor an application:

  1. Start the IBM Support Assistant workbench.
  2. On the Home page, click the Analyze Problem tab.
  3. Select IBM Monitoring and Diagnostic Tools for Java - Health Center from the Tools catalog and click the Launch button (Figure 7).
    Figure 7. Launch Health Center
    Figure 7. Launch Health Center
  4. The Connection Wizard opens (Figure 8). Click Next.
    Figure 8. Connection wizard
    Figure 8. Connection wizard
  5. On theJVM Connection Details panel (Figure 9), specify the host name you wish to connect to and accept the default port number. Click Next to start searching for Health Center agent listening ports. By default, the search begins with port 1972 and scans the next 100 ports to find all listening agents. If you already know the listening port for the agent you want to connect to, you can enter that number and uncheck the Scan next 100 ports for available connections check box. If there is a firewall between the client and the agents, then be sure to open the necessary ports.
    Figure 9. JVM Connection Details
    Figure 9. JVM Connection Details
  6. When the search completes, the final panel of the wizard shows the available agent connections (Figure 10). Select a port from the list and click Finish to connect.
    Figure 10. Final Connection wizard panel
    Figure 10. Final Connection wizard panel

What's your WebSphere application really doing?

You can now look to see what your application is doing and how you can optimize it to do it faster.

For the purpose of demonstrating how you would use the Health Center to accomplish these tasks, let’s look at the Plants By WebSphere sample Web application. Follow along to see how a small change to the application can have a significant impact on performance.

The change that was made to the Plants By WebSphere application was to add a small bit of dynamic content to the Web page; specifically, the current year was added to the name of each plant that displays on the page. No changes were made to the backing database, just to the code which returns the name: Inventory.getName(). The current year was then worked out by constructing a Date object, formatted as a string, and then a regular expression was used to parse out the year. Figure 11 shows the result of these changes.

Figure 11. The updated Plants By WebSphere application
Figure 11. The updated Plants By WebSphere application

Now, let’s use Health Center to see the impact of these changes:

  • How does the change impact garbage collection?

    What is the performance impact of these changes? To understand this, the first thing you need to check is garbage collection. In the Garbage Collection perspective, Health Center shows graphs of garbage collection activity, GC statistics, and recommendations (Figure 12).

    Figure 12. Garbage Collection perspective
    Figure 12. Garbage Collection perspective

    As you can see from the graphs in Figure 12, the GC pauses are not excessively long, but there does seem to be quite a bit of GC activity. You can confirm this by looking at the summary, which shows 6.2% of the application's time is spent in garbage collection. Although 6.2% GC overhead isn't excessive, it's significantly higher than the 2.6% overhead of the original application (Figure 13).The rate of garbage generation is also six times higher, so the new application is generating far more garbage.

    Figure 13. Summary garbage collection table for original application
    Figure 13. Summary garbage collection table for original application
  • How does the change affect execution efficiency?

    Next, check the percentage of the CPU consumed by using the Date object. Is it running efficiently? The Health Center’s Profiling perspective can help answer this question. Sometimes the profile can be dominated by WebSphere Application Server code and it can be hard to find your application code. To see just your code, you can use the filtering capability (Figure 14). Use regular expressions for more complex filtering (an asterisk (*) is always added to the beginning and end of the filter string, so there's no need to add wildcards for simple strings). This example uses "plant" as a filter so that only Plants By WebSphere methods are profiled.

    Figure 14. Use the filtering capability in the Profiling perspective
    Figure 14. Use the filtering capability in the Profiling perspective

    The Health Center's Profiling perspective gives a method profile collected by regularly sampling the executing code. In this case (Figure 15), the Self (%) column shows that 3.2% of CPU time is spent in Date.toString(). The Tree (%) column shows the cumulative amount of CPU time (40.6%) is spent by Date.toString() and all of the methods that it calls. Date.toString() is responsible for more than 40% of the application's CPU usage.

    Figure 15. Method profile
    Figure 15. Method profile

    The invocation path view (Figure 16) shows which code is calling Date.toString(). In this case, 100% of the calls come from the changed method, Inventory.getName().

    Figure 16. Invocation paths of Date.toString()
    Figure 16. Invocation paths of Date.toString()

    Clearly, formatting dates as strings is costly. If you were to improve performance here, you could cache the string instead of re-creating it for every item in the inventory. The profile (Figure 15) also shows that quite a lot of time is being spent in regular expression processing, so you should also cache the parsing results. Better yet, use a method of working out the date which avoids creating extra strings and regular expression matching, such as Calendar.get(Calendar.YEAR).

  • How is your synchronization doing?

    The code change in this example did not involve any synchronization and so there are no issues with the locking behavior of the application. Therefore, it is unlikely that synchronization will have a significant performance impact in this example (Figure 17).

    Figure 17. Locking perspective
    Figure 17. Locking perspective
  • What configuration is your application running with?

    The Health Center Environment perspective (Figure 18) shows the Java configuration, system properties, and environment variables of the monitored process. This can be useful for confirming whether the intended JVM is being monitored and whether WebSphere applications are running with the intended configurations.

    Figure 18. Environment perspective
    Figure 18. Environment perspective

Conclusion

IBM Monitoring and Diagnostic Tools for Java - Health Center enables you to monitor the performance and behavior of a WebSphere Application Server application in a lightweight, always-on way. It can easily and clearly help you identify and diagnose performance, configuration, and synchronization problems.

Resources

Learn

Get products and technologies

Discuss

Comments

developerWorks: Sign in

Required fields are indicated with an asterisk (*).


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Information in your profile (your name, country/region, and company name) is displayed to the public and will accompany any content you post, unless you opt to hide your company name. You may update your IBM account at any time.

All information submitted is secure.

Choose your display name



The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

Required fields are indicated with an asterisk (*).

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


All information submitted is secure.

Dig deeper into Business process management on developerWorks


static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Business process management, WebSphere, Java technology
ArticleID=442780
ArticleTitle=The Support Authority: Know what your Web application is really doing
publish-date=11042009