Profile your remote WebSphere application using Rational Application Developer

Enable profiling for either the Java Profiler agent or the J2EE Request Profiler

Learn how to configure IBM® Rational® Application Developer and WebSphere® Application Server to profile your remote WebSphere application. This article provides steps for setting up either Java™ profiling or the J2EE Request Profiler.

Share:

Keerthana Sharath (Keerthana.sharath@in.ibm.com), Application Integration & Middleware Solutions Specialist, IBM India Pvt. Ltd.

Photo of K. SharathKeerthana Sharath is an Application Integration & Middleware Solutions Specialist with IBM India Software Labs, WebSphere Lab Services for over 4 years now. She has worked on customer engagements involving various products including WebSphere Application Server, WebSphere Process Server, ILOG and Lombardi. She has worked with WebSphere Education Development to develop and deliver WebSphere courses and is a certified WebSphere Application Server and Process Server Administrator.



05 October 2011

Also available in Chinese

Overview

Application profiling is an analysis technique used to collect runtime data and detect application problems such as memory leaks, performance bottlenecks, excessive object creation, and exceeding system resource limits. Rational® Application Developer Version 7.5, an integrated development environment (IDE) for Enterprise Application development, is a popular choice for developing large applications for eventual deployment on WebSphere® Application Server. Rational Application Developer gives you the ability to profile Java™ applications, providing insight into the performance and memory characteristics of your application.

Two types of profilers can be used on an application:

  • Java Profiler. The Java Profiler is a standards-based Java application profiler tightly integrated into the Eclipse development workflow. The Java Profiling Agent provides detailed information about the runtime behavior of either standalone applications or applications running on an application server. It is an agent instance that is deployed with the Agent Controller.
  • J2EE Request Profiler. The J2EE Request Profiler is an agent that resides within the application server process for the purpose of collecting data from the interception points of the e-business application's requests. It uses Agent Controller to externalize this data so that it can be rendered by the various views provided by the Profiling and Logging perspective of the workbench. The J2EE Request Profiler provides higher-level data about the application.

Knowing more about your application's run-time behavior provides a better understanding of its resource requirements and potential bottlenecks that can occur at runtime. Profiler aids problem determination and provides useful insights on the parameters to be tuned for better performance of the application.

This article is for developers, performance tuning specialists, or consultants. It describes the process of profiling applications running on WebSphere Application Server Version 8.0 using the profiling features of Rational Application Developer Version 7.5. The steps to configure an external Application Server instance with the Rational Application profiler are different from the steps needed if the application is integrated with Rational Application Developer.

Prerequisites

This article assumes the following prerequisites:

  • You must be familiar with Rational Application Developer and have used it as a development tool.
  • You need to have a good understanding of the Application Server environments and creation profiles.
  • You need to have hands-on experience in configuring Application Server and performing administrative activities.

The system requirements are:

  • Microsoft® Windows®
  • Rational Application Developer Version 7.5 (IBM Rational Agent Controller is packaged in the Application Developer install image and therefore no separate installation step is required.)
  • WebSphere Application Server Version 8.0 ND and a Cell profile (Dmgr01 and AppSrv01 federated to it)

As shown in Figure 1, Rational Application Developer can run on a separate machine from WebSphere Application Server, or on the same machine. This article describes how to connect to and enable profiling when the target WebSphere application server instance is on a local or remote machine (not a WebSphere test environment integrated with Rational Application Developer).

Figure 1. Machine setup for application profiling
Diagram of machine setup

Set the environment variables

The following directories are used as the installation paths for the components.

  • Agent Controller root: C:\IBM\SDP_1\AgentController
  • Application Server root: C:\IBM\WebSphere\AppServer
  • Rational Application Developer root: C:\IBM\SDP

Before you start Application Server and Rational Application Developer, you must set certain environment variables on the machine where the target application is running, .

  1. Edit the SetupCmdLine.bat file under C:\IBM\WebSphere\AppServer\profiles\AppSrv01\bin by adding the statements in Listing 1 at the end of the file.
Listing 1. Setting environment variables
SET TPTP_AC_HOME=C:\IBM\SDP_1\AgentController

SET JAVA_PROFILER_HOME=%TPTP_AC_HOME%\plugins\org.eclipse.tptp.javaprofiler

SET PROBEKIT_HOME= \
C:\IBM\SDPShared\plugins\org.eclipse.hyades.probekit_4.2.400.v200809010100\os\win32\x86

SET BOOT_LOADER= C:\IBM\SDPShared\plugins\
org.eclipse.tptp.platform.jvmti.runtime_4.4.200.v200809010100\agent_files\win_ia32

SET LD_LIBRARY_PATH= \
%TPTP_AC_HOME%\bin;%TPTP_AC_HOME%\lib;%PROBEKIT_HOME%;%LD_LIBRARY_PATH%;%BOOT_LOADER%

SET PATH= \
%TPTP_AC_HOME%\bin;%TPTP_AC_HOME%\lib;%PROBEKIT_HOME%;%JAVA_PROFILER_HOME%;%PATH%
  1. Save and close the SetupCmdLine.bat file.

Configure WebSphere Application Server

You need to configure the Application Server so that the Rational Application Developer Profiler can attach to it.

  1. Start the Deployment Manager. Open a command prompt and navigate to C:\IBM\WebSphere\AppServer\profiles\Dmgr01\bin (where Dmgr01 is the deployment manager profile in our example). Enter the command startManager.bat.
    Figure 2. Start the deployment manager
    Screen shot of commandline for starting deployment manager
  2. Start the node agent. Navigate to C:\IBM\WebSphere\AppServer\profiles\AppSrv01\bin (where AppSrv01 is the node in our example). Enter the command startNode.bat.
    Figure 3. Start the node manager
    Screen shot of commandline for starting node
  3. Stop the AppSrv01 by navigating to C:\IBM\WebSphere\AppServer\profiles\AppSrv01\bin and entering the command stopServer.bat server1.
  4. Launch the Administrative console of Dmgr01 by opening a browser and navigating to the following address on the Application Server machine: http://localhost:9060/ibm/console
  5. The application server must be started with profiling enabled. In the Administrative Console, navigate to Servers > Server Types > WebSphere application servers > server1> Java and Process Management > Process definition > Java Virtual Machine.

    For profiling with Java Profiling Agent, enter the following in the Generic JVM arguments field: -agentlib:JPIBootLoader=JPIAgent:server=controlled;CGProf

    See Generic JVM arguments for more information.

    Figure 4. Enabling the Java profiling agent
    Admin console panel for enabling profile

    For profiling with J2EE Request Profiler, enter -DPD_DT_ENABLED=true.

    Figure 5. Enabling the J2EE Request profiler
    Panel for enabling the J2EE Request profiler
    Click OK and Save configuration changes.
  6. Start server1. Open a command prompt and navigate to C:\IBM\WebSphere\AppServer\profiles\AppSrv01\bin. Enter the command startServer.bat server1.
    Figure 6. Starting the application server
    Screen shot of commandline for starting the application server

    When the Generic JVM arguments field is set for the Java Profiling agent, the server start appears hung (Figure 6) because it is waiting for a signal from Rational Application Developer in this "controlled" profiling mode. Proceed to the next step.


Configure the profiler in Rational Application Developer

JVM argument syntax

This section details the generic JVM argument syntax that must be used in the Application Server Administrative Console to enable Profiling.

Use the -agentlib option to invoke the Java Profiling Agent: -agentlib:JPIBootLoader=JPIAgent:server=[< > ];<Profiler>. The command line is structured as follows:

  • JPIBootLoader. The library that loads the profiling agent.
  • JPIAgent. The Java 5.0+ profiling agent. By augmenting the JPIAgent part of the command line with additional options, you can control the behavior of the profiling agent. The following options are supported:
    server=[standalone | enabled | controlled]
  • standalone. The profiling agent runs in a headless mode, which means it is not possible to interact with it from the workbench. Configuration information is provided as part of the command-line interface and profiling data is stored in a file directly by the profiling agent. The profiling file can then be imported into the workbench at a later date. The Java Profiling Agent is manually attached to a JVM instance and generates profiling data to an output file. The default output file is called trace.trcxml, but you can specify a different file name using the file= filename parameter. When this option is selected, the Java Profiling Agent produces an enclosing traceRoot element to form a complete and valid XML document.
  • enabled (This is the default.) The profiling agent runs in the background of the JVM without consuming resources until it is connected to by the workbench and asked to start monitoring. Data is then streamed over the agent's data channel and consumed by the workbench. This mode allows the application to run normally, but produces no profiling data until a client attaches to the agent to give it instructions. When this option is selected, the Java Profiling Agent produces only XML fragments instead of a complete XML document.
  • controlled The profiling agent preempts the JVM from initialization (the agent is loaded but it blocks the application from running) until it is attached to from the workbench and given instructions to start monitoring by a client. That is, when the profiling agent is launched in controlled mode, it appears to hang the JVM until asked to start monitoring and it produces only XML fragments instead of a complete XML document.
  • <Profiler> The name of the Profiler Library to load. Some of the available profilers support additional profiler-specific options, such as CGProf (execution time analysis), HeapProf (object allocation/heap analysis), and ThreadProf (thread analysis).

The next step is to configure the Rational Application Developer profiler. Perform these steps on the machine where Rational Application Developer is installed.

  1. Configure and start the Agent Controller.

    1. Open a command prompt and navigate to C:\IBM\SDP_1\AgentController\bin. Run the SetConfig.bat script to generate the configuration file for the Agent Controller
    2. The Agent Controller can be started as an application or as a Windows Service. To start as an application, enter the command ACServer.exe from the C:\IBM\SDP_1\AgentController\bin directory.
  2. Start Rational Application Developer. In a command window navigate to C:\IBM\SDP and enter the command eclipse.exe.
  3. Once the program has been started, go to the Profiling Perspective. To open this perspective:

    1. Click Window > Open Perspective > Other...
    2. Select Profiling and Logging from the list and click OK.
    Figure 7. Profiling and logging perspective
    The profiling and logging perspective within RAD
  4. Attach to a Remote Java process for the server instance:

    1. Select Run > Profile Configurations.... In the configuration window double-click Attach to Agent and click New_configuration.
    2. Enter a name for your configuration.
    3. On the Host tab, in the Default Hosts section, select the address of the local host--for example, localhost[10002]. If you are configuring on a remote server, enter the hostname or IP address of the remote machine. Click OK.
    4. Click Test Connection to verify that the communication works. If the connection fails, check if the Agent Controller is running using the default port.
      Figure 8. Test the connection
      Testing the connection within RAD
    5. Next select the Agents tab. If you had set the JVM arguments for Java Profiling agent earlier, then the agent Java Profiling -- JRE 1.5 or newer should be listed. Expand the twisty to find Execution Time Analysis. Check both.
      Figure 9. Profile using Java Profiler
      Profile using Java Profiler

      If you had set the JVM arguments for J2EE Request Profiler earlier, then the agent J2EE Request Profiler should be listed. Check the agent listed.

      Figure 10. Profile using J2EE Request Profiler
      Profile using J2EE Request Profiler
    6. Select the Common and Destination tabs to view additional configuration options, such as specifying the profiling project. You can modify values on these two tabs as needed, but additional configuration is not required for this example.
    7. Switch back to Agents Tab and click Profile.

    8. Once monitoring begins, you are ready to start profiling the application. Note the Process ID (PID) of server1 from the Profiling Monitor tab as shown in Figure 11 and Figure 12.
      Figure 11. Execution Time Analysis - Java Profiling
      Execution Time Analysis - Java Profiling
      Figure 12. J2EE Request Profiler
      J2EE Request Profiler

Profile the application and analyze views

Once the Profiler has been configured, the application to be profiled can be accessed via the URL http://localhost:9080/< application_name >. The profiling data is captured and can be analyzed in Rational Application Developer.

Java Profiler views. To open a new view, right-click <monitoring....collecting> Profiling (date) > Open With. You have several options to choose from:

  • Execution Time Analysis
  • Memory Statistics
  • Thread Statistics
Figure 13. Java profiler view
RAD view of Java profiler

Execution statistics for a sample application are shown in Figure 14.

Figure 14. Sample execution statistics
Sample execution statistics

J2EE Request Profiler views. To open a new view, right-click <monitoring....collecting> J2EE Request Profiler (date) - > Open With. You have several options to choose from--for example, UML2 Object Interactions, UML2 Class Interactions, and UML2 Thread Interactions

To display the captured data in the Profiling Perspective, right-click in the Profiling Monitor view and select Refresh Views. This updates the data for all views. Once the data has been displayed, the view must be refreshed again in order to display newly captured data.

Figure 15. J2EE Request Profiler
J2EE Request Profiler

Memory statistics of a sample application are shown in Figure 16.

Figure 16. Sample memory statistics
Sample memory statistics

More information on each of these views is found in the appropriate modes below. The four levels are:

  • Package
  • Class
  • Method
  • Instance

You can switch between the package, class, method, and instance modes by selecting the appropriate toolbar control.

Resources

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 WebSphere on developerWorks


static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=WebSphere, Java technology
ArticleID=763032
ArticleTitle=Profile your remote WebSphere application using Rational Application Developer
publish-date=10052011