Integrating NetBeans Profiler with Web Server 7.0

While looking into some performance issues,  I needed to profile Web Server 7.0 I have used OptimizeIt and Jprobe before but NetBeans had just released its new version of profiler and I thought I'll give it a try and was amazed with the new NetBeans profiler. I've used both 5.0 and 5.5 and am looking forward to the next release 6.0. For now, you can download NetBeans 5.5 from here. Also check out the profiler web site for tutorials, documentation, FAQs, blogs.

Normally profiling simple applications is easy but setting up a profiler to work on a web or application server requires some extra work. Firstly I found NetBeans Profiler very easy to configure. I was able to integrate the profiler with Web Server 7.0 right in first attempt without having to refer to any documentation! Secondly, I found it to be very powerful, it has a range of performance tasks. Finally, the performance of the profiler itself is quite good, it runs with very little overhead.

Before talking about how to integrate this profiler with Web Server 7.0,  I have to mention the top 5 features of this profiler:
  • It uses dynamic byte code instrumentation which basically makes use of JVM functionality to extract and inject byte codes during run time to generate events (on method entry, exit and so on) which is then used to gather performance statistics and display to user. What this basically means to the end user is that profiling tasks can be managed during run time without having to restart the application! For example you can do one run of collecting CPU performance data, reset the results then enable threads monitoring and monitor the threads usage.
  •  There are numerous performance tasks like CPU performance, memory analyzer, threads profiling, code fragment profiling (you no longer need to modify your code to include System.currentTimeMillis(), code fragment profiling does the job for you!)
  • It is tightly integrated into NetBeans IDE which means that you have a code browser, debugger and  profiler all within the same environment.
  • Runs with very little overhead.
  • Allows for local as well as remote profiling.
I have used the profiler on Solaris, Windows and Linux (Ubuntu) successfully.

Before going further, here are a couple of snapshots just to show you what it looks like.

1. This is a screenshot of the profiler console. You have controls to start, stop, reset results buffer, change profiling task, view VM telemetry etc. You can also take snapshot or monitor live results. You also have options to manage the snapshots (i.e open, delete, export, load)

Profiler Console Screenshot

2. This is a screenshot of profiling task wizard:

Profiling Task Wizard

3. Here is a CPU performance screenshot:
  CPU snapshot

4. Here is a screenshot of threads profiling:

Threads Snapshot

To start with, you'll need to do the following:

1. Download and install J2SE 5.0, Update 4 or higher
2. Download and install NetBeans IDE 5.0 or 5.5
3. Download and install NetBeans Profiler 5.0 or 5.5
4. Open the IDE and you will see a separate Profile tab.
5. First time profile on a machine on target VM requires some calibration, this is a one time task
     Profile -> Advanced Commands -> Run Profiler Calibration

You are now set up to integrate the profiler with Web Server 7.0

Profiling Web Server 7.0

To integrate the profiler with Web Server 7.0, you will basically need to configure the web server instance to load the NetBeans agent library. You can perform the same using the new administration CLI tool wadm

Step 1: Make sure the administration server is running and connect to it

bash-3.00$ wadm -u admin -w /build/admin.pwd
Sun Java System Web Server 7.0-Technology-Preview-3 B11/03/2006 10:10

Step 2:  Create a JVM profiler for the web server instance that you want to profile

wadm> create-jvm-profiler --config=test NetBeans
CLI201 Command 'create-jvm-profiler' ran successfully
wadm> list-jvm-profilers --config=test
wadm> list-jvm-profilers --config=test --all --verbose
name    enabled
NetBeans        true

Step 3: Add the options to load the agent library while starting the instance. If you invoke the NetBeans profiler wizard, it will show you the option to be inserted.

wadm> create-jvm-options --config=test --profiler=NetBeans -- -agentpath:/space/netbeans-5.5beta2/profiler1/lib/
CLI201 Command 'create-jvm-options' ran successfully
wadm> list-jvm-options --config=test --profiler=NetBeans

Step 4: Deploy the configuration to the instance

wadm> deploy-config  test
CLI201 Command 'deploy-config' ran successfully

Step 5:  Start the NetBeans IDE

Step 6:  Click on Profile -> Attach Profiler -> Attach Wizard

Step 7:  Select Target Type as J2EE Web/App Server, Server Type as Generic Web/App Server and click Next

Step 8:  Choose Server Location (local or remote) . If you select remote you will need to enter the remote host name and select host OS type. Select Attach Method as direct and click Next

Step 9:  Choose Target JVM as 'Java5.0_04 and newer'  and click Next

Step 10:  The screen will list some steps that we've already performed in steps 1-3. Click Finish

Step 11:  Before actually attaching the profiler, make sure you start the instance. You will see the following log messages in the server instance :

[14/Nov/2006:16:03:27] fine (24735): After calling restart functions
[14/Nov/2006:16:04:17] info (24751): CORE1116: Sun Java System Web Server 7.0-Technology-Preview-3 B11/03/2006 10:54
[14/Nov/2006:16:04:17] warning (24752): CORE3283: stderr: Profiler Agent: Initializing...
[14/Nov/2006:16:04:17] warning (24752): CORE3283: stderr: Profiler Agent: Options: >/space/netbeans-5.5beta2/profiler1/lib,5140<
[14/Nov/2006:16:04:17] warning (24752): CORE3283: stderr: Profiler Agent: Initialized succesfully
[14/Nov/2006:16:04:17] info (24752): CORE3282: stdout: Profiler Agent: Waiting for connection on port 5140 (Protocol version: 2)

Once you select the profiling task and click on Attach, the instance startup will continue. In this case I performed a remote attach.

[14/Nov/2006:16:10:15] info (24752): CORE3282: stdout: Profiler Agent: Established remote connection with the tool
[14/Nov/2006:16:10:18] info (24752): CORE5076: Using [Java HotSpot(TM) Server VM, Version 1.5.0_09] from [Sun Microsystems Inc.]
[14/Nov/2006:16:10:26] info (24752): HTTP3072: http-listener-1: http://syrinx:1894 ready to accept requests
[14/Nov/2006:16:10:26] info (24752): CORE3274: successful server startup

Thats all it takes to integrate NetBeans Profiler with Web Server 7.0!


Hi, Do you know how/what I can set the jvm options in step3 if it is window platform ? I may ask this question to webserver team but I hope can get the answer from you quickly ~ thanks, beomsuk

Posted by Beomsuk Kim on May 14, 2007 at 05:18 PM IST #

Post a Comment:
  • HTML Syntax: NOT allowed



« June 2016