You can use a profiler to perform remote profiling on the Sun Java System Web Server 7.0 to discover choke point in server-side performance. This section describes how to configure these profilers for use with Sun Java System Web Server 7.0:
HPROF is a simple profiler agent shipped with the Java 2 SDK. It is a dynamically linked library that interacts with the JavaTM Virtual Machine Profiler Interface (JVMPI) and writes out profiling information either to a file or to a socket in ASCII or binary format. This information can be further processed by a profiler front-end tool such as HAT.
HPROF can present CPU usage, heap allocation statistics, and monitor contention profiles. In addition, it can also report complete heap dumps and states of all of the monitors and threads in the Java virtual machine. For more details on the HPROF profiler, see the JDK documentation at:
http://java.sun.com/j2se/1.4.2/docs/guide/jvmpi/jvmpi.html
Once HPROF is installed, its libraries are loaded into the server process.
You can configure Sun Java System Web Server 7.0
Access the Admin Console.
Click the Edit Java Settings tab in the home page.
The JVM General Settings screen appears.
Click Profilers.
Click New.
The Create JVM Profiler popup appears.
Type the Name and select the JVM Profiler option to enable the profiler. Leave the Class Path and Native Library Path fields blank.
Click New to configure the JVM options.
Click OK.
Edit the server.xml file as appropriate
<! --hprof options --> <profiler name="hprof" enabled="true" <jvm-options> -Xrunhprof:file=log.txt,options </jvm-options> </profiler>
Do not use the -Xrs flag.
Here is an example of options you can use:
-Xrunhprof:file=log.txt,thread=y,depth=3
The file option is important because it determines where the stack dump is written in step 6.
The syntax of HPROF options is as follows:
-Xrunhprof[:help]|[:option=value,option2=value2, ...] |
Using help lists options that can be passed to HPROF. The output is as follows:
Hprof usage: -Xrunhprof[:help]|[:<option>=<value>, ...] Option Name and Value Description Default heap=dump|sites|all heap profiling allcpu=samples|old CPU usage offformat=a|b ascii or binary output afile=<file> write data to file java.hprof(.txt for ascii) net=<host>:<port> send data over a socket write to filedepth=<size> stack trace depth 4cutoff=<value> output cutoff point 0.0001lineno=y|n line number in traces? ythread=y|n thread in traces? ndoe=y|n dump on exit? y
Change the PRODUCT_BIN assignment in the /install_dir/instance_dir/bin/startserv file from:
PRODUCT_BIN=webservd-wdog to PRODUCT_BIN=webservd
Start the server by running the startserv script.
As the server runs in the foreground, the command prompt returns only after the server has been stopped.
Find the process ID of the server process in another window or terminal.
% ps -ef | grep webservd
This command lists two webservd processes. Look at the PPID (parent process ID) column and identify which of the two processes is the parent process and which is the child process. Note the PID (process ID) of the child process ID.
Send a SIGQUIT signal (signal 3) to the child process:
% kill -QUIT child_PID
Run the stopserv script from another window to stop the Web Server.
% ./stopserv
Stopping the server writes an HPROF stack dump to the file you specified using the file HPROF option. For general information about using a stack dump, see Generating a Stack Trace for Debugging.
Information about Optimizeit is available at:
http://www.borland.com/optimizeit/
Once Optimizeit is installed, its libraries are loaded into the server process.
To enable remote profiling with Optimizeit, do one of the following:
Go to the Common Tasks page in the Admin Console, click the Edit Java Settings tab, click the Profiler link, and edit the following fields before selecting OK:
Profiler: Enable
Classpath: Optimizeit_dir/lib/optit.jar
Native Lib Path: Optimizeit_dir/lib
JVM Option: For each of these options, type the option in the JVM Option field, select Add, then check its box in the JVM Options list:
-DOPTITHOME=Optimizeit_dir
-Xrunoii
-Xbootclasspath/a:Optimizeit_dir/lib/oibcp.jar
or
Enable remote profiling by editing server.xml file
<!-- Optimizeit options --> <profiler classpath="Optimizeit_dir/lib/optit.jar" nativelibrarypath="Optimizeit_dir/lib" enabled="true"> <jvm-options> -DOPTIT_HOME=Optimizeit_dir -Xboundthreads -Xrunoii -Xbootclasspath/a:Optimizeit_dir/lib/oibcp.jar </jvm-options> </profiler>
In addition, you might need to set the following in your server.policy file:
grant codeBase "file:Optimizeit_dir/lib/optit.jar" { permission java.security.AllPermission; };
For more information about the server.policy file, see The server.policy File.
When the server starts up with this configuration, you can attach the profiler.
If any of the configuration options are missing or incorrect, the profiler might experience problems that affect the performance of the Sun Java System Web Server 7.0.