WebLogic Server Performance and Tuning
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
The Java virtual machine (JVM) is a virtual "execution engine" instance that executes the bytecodes in Java class files on a microprocessor. How you tune your JVM affects the performance of WebLogic Server and your applications. envelope
The following sections discuss JVM tuning options for WebLogic Server:
Table 5-1 presents general JVM tuning considerations for WebLogic Server.
Use only production JVMs on which WebLogic Server has been certified. This release of WebLogic Server supports only those JVMs that are J2SE 5.0-compliant. The Supported Configurations pages are frequently updated and contains the latest certification information on various platforms. |
|
For WebLogic Server heap size tuning details, see Garbage Collection. |
|
Depending on your application, there are a number of GC schemes available for managing your system memory, as described in Choosing a Garbage Collection Scheme. |
|
Deployments using different JVM versions for the client and server are supported in WebLogic Server. See the support page for Mixed Client/Server JVMs. |
|
Choices you make about Solaris threading models can have a large impact on the performance of your JVM on Solaris. You can choose from multiple threading models and different methods of synchronization within the model, but this varies from JVM to JVM. See Performance Documentation For the Java Hotspot Virtual Machine: Threading on Sun Microsystems' Web site. |
Although this section focuses on Sun Microsystems' J2SE 5.0 JVM for the Windows, UNIX, and Linux platforms, the BEA JRockit JVM was developed expressly for server-side applications and optimized for Intel architectures to ensure reliability, scalability, manageability, and flexibility for Java applications. For more information about the benefits of using JRockit on Windows and Linux platforms, see Introduction to JRockit JDK.
For more information on JVMs in general, see the Introduction to the JVM specification. For links to related reading for JVM tuning, see Related Reading: Performance Tools and Information.
When you create a domain, if you choose to customize the configuration, the Configuration Wizard presents a list of JDKs that WebLogic Server installed. From this list, you choose the JVM that you want to run your domain and the wizard configures the BEA start scripts based on your choice. After you create a domain, if you want to use a different JVM, see Changing the JVM That Runs Servers .
Garbage collection is the VM's process of freeing up unused Java objects in the Java heap. The following sections provide information on tuning your VM's garbage collection:
The Java heap is where the objects of a Java program live. It is a repository for live objects, dead objects, and free memory. When an object can no longer be reached from any pointer in the running program, it is considered "garbage" and ready for collection. A best practice is to tune the time spent doing garbage collection to within 5% of execution time.
The JVM heap size determines how often and how long the VM spends collecting garbage. An acceptable rate for garbage collection is application-specific and should be adjusted after analyzing the actual time and frequency of garbage collections. If you set a large heap size, full garbage collection is slower, but it occurs less frequently. If you set your heap size in accordance with your memory needs, full garbage collection is faster, but occurs more frequently.
The goal of tuning your heap size is to minimize the time that your JVM spends doing garbage collection while maximizing the number of clients that WebLogic Server can handle at a given time. To ensure maximum performance during benchmarking, you might set high heap size values to ensure that garbage collection does not occur during the entire run of the benchmark.
You might see the following Java error if you are running out of heap space:
java.lang.OutOfMemoryError <<no stack trace available>>
java.lang.OutOfMemoryError <<no stack trace available>>
Exception in thread "main"
To modify heap space values, see Specifying Heap Size Values.
To configure WebLogic Server to detect automatically when you are running out of heap space and to address low memory conditions in the server, see Automatically Logging Low Memory Conditions and Specifying Heap Size Values.
Depending on which JVM you are using, you can choose from several garbage collection schemes to manage your system memory. For example, some garbage collection schemes are more appropriate for a given type of application. Once you have an understanding of the workload of the application and the different garbage collection algorithms utilized by the JVM, you can optimize the configuration of the garbage collection.
Refer to the following links for in-depth discussions of garbage collection options for your JVM:
The verbose garbage collection option (verbosegc
) enables you to measure exactly how much time and resources are put into garbage collection. To determine the most effective heap size, turn on verbose garbage collection and redirect the output to a log file for diagnostic purposes.
The following steps outline this procedure:
-verbosegc
option to turn on verbose garbage collection output for your JVM and redirect both the standard error and standard output to a log file.This places thread dump information in the proper context with WebLogic Server informational and error messages, and provides a more useful log for diagnostic purposes.
For example, on Windows and Solaris, enter the following:
% java -ms32m -mx200m -verbosegc -classpath $CLASSPATH
-Dweblogic.Name=%SERVER_NAME% -Dbea.home="C:\bea"
-Dweblogic.management.username=%WLS_USER%
-Dweblogic.management.password=%WLS_PW%
-Dweblogic.management.server=%ADMIN_URL%
-Dweblogic.ProductionModeEnabled=%STARTMODE%
-Djava.security.policy="%WL_HOME%\server\lib\weblogic.policy" weblogic.Server
>> logfile.txt 2>&1
where the logfile.txt 2>&1
command redirects both the standard error and standard output to a log file.
On HPUX, use the following option to redirect stderr
stdout
to a single file:
where $$
maps to the process ID (PID) of the Java process. Because the output includes timestamps for when garbage collection ran, you can infer how often garbage collection occurs.
Use as large a heap size as possible without causing your system to "swap" pages to disk. The amount of free RAM on your system depends on your hardware configuration and the memory requirements of running processes on your machine. See your system administrator for help in determining the amount of free RAM on your system.
Note: JVM vendors may provide other options to print comprehensive garbage collection reports. For example, you can use the BEA JRockit JVM -Xgcreport
option to print a comprehensive garbage collection report at program completion, see .
System performance is greatly influenced by the size of the Java heap available to the JVM. This section describes the command line options you use to define the heap sizes values.You must specify Java heap size values each time you start an instance of WebLogic Server. This can be done either from the java
command line or by modifying the default values in the sample startup scripts that are provided with the WebLogic distribution for starting WebLogic Server.
The following section provides general guidelines for tuning VM heap sizes:
Although BEA JRockit provides automatic heap resizing heuristics, they are not optimal for all applications. In most situations, best performance is achieved by tuning the VM for each application by adjusting the heaps size options shown in Table 5-2.
For example, when you start a WebLogic Server instance from a java
command line, you could specify the BEA JRockit VM heap size values as follows:
$ java -Xns10m -Xms512m -Xmx512m
The default size for these values is measured in bytes. Append the letter `k' or `K' to the value to indicate kilobytes, `m' or `M' to indicate megabytes, and `g' or `G' to indicate gigabytes. The example above allocates 10 megabytes of memory to the Nursery heap sizes and 512 megabytes of memory to the minimum and maximum heap sizes for the WebLogic Server instance running in the JVM.
For detailed information about setting the appropriate heap sizes for WebLogic's JRockit JVM, see Tuning the JRockit JVM.
BEA provides other command-line options to improve the performance of your BEA JRockit VM. For detailed information, see .
You achieve best performance by individually tuning each application. However, configuring the Java HotSpot VM heap size options listed in Table 5-3 when starting WebLogic Server increases performance for most applications.
These options may differ depending on your architecture and operating system. See your vendor's documentation for platform-specific JVM tuning options.
For example, when you start a WebLogic Server instance from a java
command line, you could specify the HotSpot VM heap size values as follows:
$ java -XX:NewSize=128m -XX:MaxNewSize=128m -XX:SurvivorRatio=8 -Xms512m -Xmx512m
The default size for these values is measured in bytes. Append the letter `k' or `K' to the value to indicate kilobytes, `m' or `M' to indicate megabytes, and `g' or `G' to indicate gigabytes. The example above allocates 128 megabytes of memory to the New generation and maximum New generation heap sizes, and 512 megabytes of memory to the minimum and maximum heap sizes for the WebLogic Server instance running in the JVM.
Sun provides other standard and non-standard command-line options to improve the performance of your VM. How you use these options depends on how your application is coded.
Test both your client and server JVMs to see which options perform better for your particular application. The Sun Microsystems Java HotSpot VM Options document provides information on the command-line options and environment variables that can affect the performance characteristics of the Java HotSpot Virtual Machine.
For additional examples of the HotSpot VM options, see:
Sun Microsystems' Java Virtual Machine document provides a detailed discussion of the Client and Server implementations of the Java virtual machine for J2SE 5.0.
WebLogic Server enables you to automatically log low memory conditions observed by the server. WebLogic Server detects low memory by sampling the available free memory a set number of times during a time interval. At the end of each interval, an average of the free memory is recorded and compared to the average obtained at the next interval. If the average drops by a user-configured amount after any sample interval, the server logs a low memory warning message in the log file and sets the server health state to "warning." See Log low memory conditions in Administration Console Online Help.
You may find it necessary to manually request full garbage collection from the Administration Console. When you do, remember that garbage collection is costly as the JVM often examines every living object in the heap. See Manually request garbage collection in Administration Console Online Help.
You may find it necessary to display thread stacks while tuning your applications. See Display thread stacks in Administration Console Online Help.
If you are running a high-stress application with heavily contended locks on a multiprocessor system, you can attempt to improve performance by using spinning. This option enables the ability to spin the lock for a short time before going to sleep.
Sun has changed the default lock spinning behavior in JDK 5.0 on the Windows IA32 platform. For the JDK 5.0 release, lock spinning is disabled by default. For this release, BEA has explicitly enabled spinning in the environment scripts used to start WebLogic Server. To enable spinning, use the following VM option:
-XX:+UseSpinning
The BEA JRockit VM automatically adjusts the spinning for different locks, eliminating the need set this parameter.
Note: In the BEA JRockit 8.1 SDK release, spinning was adjusted by setting -XXenablefatspin
option.
![]() ![]() |
![]() |
![]() |