Friday, April 10, 2009

Using JProfiler for JBoss running on Solaris SPARC

JProfiler

Jprofiler is a profiling tool written in pure Java which can be used to profile applications running in any JVM implementation. There are two components to it. One is the Agent which gets deployed to a machine where the application will be profiled and the other is just basically a GUI Client that displays the statistics on Memory, CPU and Threads. The data presented at the client are real time which can be used to analyze performance bottlenecks, memory leaks, threading issues.

Setup and Configuration for Solaris SPARC

Requirements for the Remote Agent
  1. Ensure installation directory of the JProfiler has right permissions and is not affected by any the regular run of of a cleanup/process engine if there's any or else you will have to redo the installation the following morning for further testing.
  2. Identify if machine supports 32-bit and/or 64-bit computing. Choose one that is supported by JProfiler, your server/client machine where the JProfiler agent and GUI JProfiler will be installed respectively. Both client and agent must have the same computing platform. Run the command "sudo isainfo –v" to determine what the machine supports.
  3. There should be two files that need to exists, in my example - in a user’s home directory. The jboss and run-jboss.profiler.sh scripts (but you can name them however you want it).

This jboss script is used to kickstart jboss . Should look like the one below.

LD_LIBRARY_PATH=/opt/jprofiler/jprofiler5/bin/solaris-sparc export LD_LIBRARY_PATH case "$1" in start) [ -x /home/staff/rgarcia/run-jboss.profiler.sh -a -d /opt/htapps ] || ex it 0 echo Starting JBoss in background... /home/staff/rgarcia/run-jboss.profiler.sh -d /opt/htapps & ;; stop) /usr/local/jboss/bin/shutdown.sh -S ;;

The run-jboss.profiler.sh is basically a script that calls the jboss run.sh script (/usr/local/jboss/bin/run.sh) and initialize the VM parameters instead of passing that activity over to run.sh. The VM arguments specific to jprofiler should look similar to the one below.

#va Overrides : ${JAVA_HOME:=/usr/local/java} : ${JAVA:=$JAVA_HOME/bin/java} : ${JAVA_HEAP_MIN_MB:=128} : ${JAVA_HEAP_MAX_MB:=512} JAVA_OPTS="$JAVA_OPTS -agentlib:jprofilerti=port=2505 -Xbootclasspath/a:/opt/jprofiler/jprofiler5/bin/agent.jar -Xms${JAVA_HEAP_MIN_MB}m -Xmx${JAVA_HEAP_MAX_MB}m -Djboss.server.base.dir=$FINAL_DEPLOY_CFG_ROOT -Djboss.server.base.url=file://$FINAL_DEPLOY_CFG_ROOT"

export JAVA_HOME JAVA JAVA_OPTS

Setting up the Jprofiler GUI Client
  1. Install JProfiler client (Windows).
  2. Create Session. Enter the URL of the machine and port number. The port number must be the same as the one configured in the run-jboss.profiler.sh script file.

Running JProfiler
  1. Run the remote application using the jboss script from the user’s home directory.
  2. On the console it should show that its waiting for the JProfiler GUI Client connection.
  3. Open the Session created from the JProfiler GUI Client.
  4. Application continues to load from the remote machine.
  5. You can choose what to profile from the GUI – Memory, CPU, Thread.
  6. You can record snapshots from the real-time statistics and export it to any image or an html or save the current session as .jps file which will save all the raw data gathered.

Please take note that if profiling is completed on the target remote application shutdown its Agent and restart the application using the normal process. 

No comments:

Post a Comment