Note 696410 - Java VM settings for EP6 on J2EE 6.20

Summary
Symptom
Configuration of Java Virtual Machine for EP SP2 on J2EE 6.20
Other terms
heap garbage collector hotspot newsize permsize SoftRefLRUPolicy
Reason and Prerequisites
Setting Java VM parameters properly improves performance and stability of the application server.
Solution

Content:
Preface
    1. Location of JVM options
    2. Java VM Version
    3. Compiler Option (don't use -server)
    4. Heap size (-Xms and -Xmx)
    5. New Space (-XX:NewSize, -XX:MaxNewSize)
    6. Permanent Space (-XX:PermSize, -XX:MaxPermSize)
    7. Allow Explicit GC (don't use -XX:+DisableExplicitGC)
    8. Soft References (-XX:SoftRefLRUPolicyMSPerMB=1)
    9. Other VM Parameters
    10. OS-specific notes and links
Preface:
I. Settings for the dispatcher node
JVM settings for the dispatcher node differ from those for the server node. A large part of the information provided below relates only to the settings for the server node.
For a dispatcher node, the heap size, -Xmx64M -Xms64M should be enough. Note that increasing the heap size for the dispatcher does not increase performance except in very special cases where the peak memory usage might exceed 64 MB (even in these exceptional cases we never needed memory higher than 128 MB for the dispatcher). No other JVM settings are needed for dispatcher nodes.
II. Platform specific settings (-XX)
The options starting with -XX are only valid for HotSpot VM (Windows, Solaris, HP UX); please don't apply them to VM settings for IBM, AIX.
Users of IBM JDK should skip the chapters 5-8 below.
III. Settings for the state controller node (PL 22 and higher)
State controller node doesn't run any applications any longer from PL22 on. Therefore it doesn't need as much ressources as an application server node.
We recommend setting -Xmx256M -Xms256M for state controller and backup state controller nodes.
1. Location of JVM settings
The JVM command line settings for SAP J2EE Engine are kept in different files depending on the way the server is started. Please refer to the note 697062.
2. JVM Version
J2EE Engine 6.20 only runs on JDK(SDK) 1.3.1. According to the availabil ity matrix at: http://service.sap.com/pam it is only released for 32-bit Java VM (except Compaq True64 and IBM OS/400 platforms which are not relevant for EP6). Please refer to note 540264 about Java installation and note 575774 about Java upgrade.

Recommendation:
    • - Use the latest available patch for 1.3.1
    • - Especially for HotSpot Virtual Machine (Win, Solaris & HP) please use JDK 1.3.1_09 or higher
    • - Do NOT use JDK 1.4
3. Compiler option

3.1 We DON'T recommend using -server option for Windows, Solaris and HP UX (this option doesn't exist in IBM JDK) because of too many JVM bugs.

3.2 Special remark for HP UX
On HP UX unlike Solaris or Windows the default VM is the Server VM, thus even if you omit -server option it will be used. To switch to the client machine you have to specify explicitly -client as the very first argument in the java command line, for example
java -client -Xmx1024M ... and so on.

3.3 Special remark for JStartup Framework users:
Jstartup Framework loads Server VM by default. To prevent it from using
Server VM please edit the file
/usr/sap/<SID>/global/profile/jcontrol_xx.pfl
and set the desired VM version:
jstartup/vm/type=hotspot (for Windows and Solaris)
jstartup/vm/type=client  (for HP UX)
Additionally (for JStartup Framework on HP UX only) add -XX:+ClientApp to service.ini at the very beginning of java parameter list.

3.4 Special remark for IBM JDK
The following option is obligatory:
-Djava.compiler=NONE
4. Heap Size

4.1 For the server node the minimum value for -Xmx is 512m.

4.2 In productive environments we recommend 1.5 GB (*) for 32-bit
and 2.5 GB for 64-bit machines. AIX, HP and Solaris need special patches/tuning to enable this heap size, see Note 492222 and chapter 10 below.
For Solaris 8 and higher no extra settings are needed and one can use even 3 GB heap.
Please refer to note 748713 for Startup Framework restrictions.

4.3 The -Xms value should be equal to -Xmx

4.4 The heap size of all Java server nodes must fit completely into the physical memory in order to avoid heavy paging on OS level. You must also consider the space needed for OS and other processes. For each Java VM on the server, all Java memory must fit completely into physical memory (no paging)!

4.5 Remark about Out of Threads situation: increasing of the heap and permanent space decreases the maximum number of threads. This is especially important for Windows installations, see note 576830.
For HP-UX please refer to note 534867.

(*) N.B.: please pay attention to restrictions 4.5, 6.3 and 6.4 for Windows installations. We recommend using additional server nodes instead of increasing of the Heap.
Please refer to notes 736462, 764215 for details on Windows specific restrictions.
5. New Space
Options -XX:NewSize, -XX:MaxNewSize and -XX:NewRatio control the size of the new generation where new objects are allocated. This is the space to traverse for small GCs. That's why if the new generation is too small the GC frequency is too high. However it's also bad if the new space is too big: the old generation should be big enough since Full GC copies the young generation there. If the free part of the old generation is smaller than the young generation area you might get OutOfMemoryError. In this case we recommend increasing of the heap (if possible) or decreasing of the newspace.
Based on the practical experiences with Enterprise Portal we found that the previously recommended value of 1/3 of the heap was too high and could cause an OutOfMemory (as described above).

We recommend to set new space size to a value between 1/6 and 1/5 of the whole heap.

Concrete set of parameters depends on the OS:
The option -XX:NewRatio does not function as documented by SUN, and is not recommended for SUN JDK. Therefore please use -XX:NewSize=value -XX:MaxNewSize=value for Solaris and Windows, for example -XX:NewSize=160m -XX:MaxNewSize=160m for -Xmx1024.
The opposite for HP UX: HP UX JDK ignores MaxNewSize setting (state May 2004) but accepts NewRatio. Therefore one could use -XX:NewRatio=5 on HP UX.
It is even better to use -Xmn option instead as recommended by HP support, it sets both NewSize and MaxNewSize to the same value on HP, for example -Xmn160m.
Don't use option -Xmn for SUN JDK!

See 9.3 below for configuration of sub-areas of the new space.
6. Permanent Space

6.1 According to note 597187 HotSpot VM may crash because of too small permanent space even if there is enough free heap space.
Please use -XX:MaxPermSize=192M (for Windows please read 6.3 below)
Please set also -XX:PermSize=192M, i.e. the initial and the maximal sizeof the permanent space shuold be equal (similar to -Xms and -Xmx).
Remark: because of the bug in the HP documentation the latter option (PermSize) is not listed tere (state February 2004). But according to the HP this option is used by the JVM.

6.2 Keep in mind that the permanent area is not a subset of the heap.
The pictures on the page http://java.sun.com/docs/hotspot/gc/index.html erroneously show permspace as a subset of the heap defined by -Xmx parameter. This is a bug in the documentation (state February 2004).

6.3 Windows users: keep the sum of Xmx and MaxPermSize  under 1.7 GB.
Otherwise the Java VM can't be properly initialized and you might find the following error message in the console (or in the launcher log of the windows service):
Error occurred during initialization of VM
Could not reserve enough space for object heap

6.4 In some special cases this upper boundary on Windows might be even lower, and then one can try to win more space by using SAP Address Space Viewer (note 129813) and rebasing some libraries.

6.5 In EP6 SP2 you're recommended to use the external JSP compilation, this helps to decrease the permspace usage.

6.6 Size of maximum permanent space must be aligned to 4 megabytes.
Otherwise you can get the following error:
"Error occurred during initialization of VM"
7. Explicit GC settings
Not recommended.
Garbage collection in Java VM is fully automated. Frequent explicit calls invoking the garbage collector can cause performance degradation and should be avoided in a production environment.
The option -XX:+DisableExplicitGC was used in the past as a workaround for a bug in older Java VM versions and for bugs in some older SAP and third-party components which were calling GC too often.
This option is not necessary anymore.
Remark: the ability to call GC explicitly may be required by external Java profilers. That's why it's important to enable explicit GC calls especially in development and test systems.
Too frequent full garbage collections are usually caused by wrong sizing or misconfiguration of the system.
Every change of the default behaviour of the Java VM should be done with full understanding of its purpose and side effects.
That's why the above option can be used temporary in exceptional cases only, if recommended by a support engineer.
8. Soft References tuning
We recommend setting -XX:SoftRefLRUPolicyMSPerMB=1.

Comments: soft references are used in various parts of the product, mostly for caches. This parameter controls the minimum lifetime of soft references before a GC is allowed to delete them. The default is 1000 (=1sec). Increasing the value (up to 10000) will keep cache objects referenced by soft references longer in the cache, thus reduce DB traffic. SUN recommendation is to use the default value and only change it in exceptional/problem cases.
However we found that setting lower values (e.g. even 1) helps for some kind of out-of-memory problems.
9. Other parameters

9.1 -Xoss, -Xss, -XX:ThreadStackSize
Do NOT play with these settings.
They can harm the performance as well as the functionality in general
(except True64 platform, note 578902, but this is not EP6 relevant).

9.2 -XX:MaxInlineSize=6 resp. -XX:FreqInlineSize=6
not needed anymore since JDK 1.3.1_09; was used as workaround for a bug in older JDK.

9.3 -XX:SurvivorRatio=2 -XX:TargetSurvivorRatio=90
These options have positive effect on the Full GC frequency and therefore are recommended.

9.4 -Xrs
Use if running as Windows service.
If the JVM is running as a service it can receive CTRL_LOGOFF_EVENT but should not initiate shutdown since the operating system will not actually terminate the process. To avoid possible interference such as this, the -Xrs command-line option has been added beginning with J2SE 1.3.1.
When the -Xrs option is used on Sun JVM, the JVM does not install a console control handler, implying that it does not watch for or process CTRL_C_EVENT, CTRL_CLOSE_EVENT, CTRL_LOGOFF_EVENT, or CTRL_SHUTDOWN_EVENT.
As a subsequence Ctrl-Break thread dumps are not available.
Please refer to Note 686254 for making of a thread dump of a JVM running as service

9.5 -verbose:gc
Recommended, very useful for error analysis, doesn't have any negativeeffects. Please refer to note 634689 for explanation and 608533 for additional settings needed to receive the verbose output from a background process.
Remark for HP UX: there is an extended version of the verbose GC which also shows the state of all sub-ares of the heap, please use -Xverbosegc on this plattform instead of the above standard option.

9.6 -showversion
Recommended, it is very useful for support (the java version appears in the logs).
Please put it at the beginning of the command line but after -server (or -hotspot or -client) option if the latter is present.
Attention: because of a bug in the service launcher please don't use this option for processes running as Windows services in non-verbose mode (i.e. if note 608533 is not applied).

9.7 -Xnoclassgc
NOT recommended.

9.8 -XX:+JavaMonitorsInStackTrace
Recommended, useful for performance and deadlock analysis, needed for Solution Manager Diagnostics Thread Dump Analyzer. No negative side-effects. Should be set explicitly for SUN JVM (Windows, Solaris), not necessary to be set for HP JVM because the latter prints the monitors by default.
10. Notes and Links:
492222  SAP Software on UNIX
534867, 590984 for HP UX configuration
667841, 667711 for AIX configuration
709053 Solaris LWP library
552522  Java Hotspot VM Memory Parameters
634689  Central Note for Memory Issues, SAP J2EE Engine 6.20
684884  Java process crashes when using the Configuration UI
690839  Forcing Java VM to create core dumps after memory corruption
690841  Analyzing Sun VM Hotspot Crash IDs
691944  Analyzing potential JIT errors for the Sun Java VM
698100  Analyzing Java VM crashes based on JNI misuse
748713  Central note for Startup Framework
736462, 764215 Windows specific restrictions for java heap

IBM diagnostic guide:
http://www-106.ibm.com/developerworks/java/jdk/diagnosis/diag131rev1.pdf

Solaris 8 Tuneable Parameters Reference Manual: http://docs.sun.com/db/doc/806-6779/6jfmsfr7j

SUN Documentation
Java HotSpot VM Options:
http://java.sun.com/docs/hotspot/VMOptions.html
How to tune Garbage collection on JVM 1.3.1:
http://java.sun.com/docs/hotspot/gc/index.html
Big Heaps and Intimate Shared Memory (ISM):
http://java.sun.com/docs/hotspot/ism.html

HP Java home:
http://www.hp.com/go/java
HP-UX Patches required for Java:
http://www.hp.com/products1/unix/java/patches/index.html
Last version of JDK may need additional patches, see
http://www.hp.com/products1/unix/java/java2/sdkrte1_3/downloads/index.html, for example Java Version 1.3.1.11 or later for PA-RISC requires the pthreads patch PHCO_29959 for HP-UX 11.0 or patch PHCO_29960 for HP-UX 11.11.
Header Data


Release Status:Released for Customer
Released on:16.09.2005  09:45:59
Master Language:English
Priority:Recommendations/additional info
Category:FAQ
Primary Component:BC-JAS Java Application Server - Please use sub-components
Secondary Components:EP-SYS-PERF Please use BC-JAS-COR or EP-PIN
Affected Releases
Software
Component
Release
From
Release
To
Release
And
subsequent
EP-PSERV
6.0
6.0
6.0
 
SAP-JEE
60
6.20
6.20
 
Related Notes


 
764215 - Problems with big java heap when started via jlaunch.exe
 
751972 - Plug-in for Analyzer: JVM Settings tuning
 
746673 - JDK support for J2EE 6.20 in vm_support.properties
 
729178 - Java VM setting for applications running on J2EE Engine 6.20
 
722787 - Java settings for XI 2.0 on J2EE 6.20
 
709053 - Solaris LWP library usage for SAP J2EE Engine
 
667841 - J2EE Engine 6.20 on AIX: how to increase the heap size
 
667711 - Max. JVM Heap Size for AIX JDK 1.3.1
 
634689 - Central Note for Memory Issues, SAP J2EE Engine 6.20
 
590984 - Please use JDK 1.3.1_05 or higher for SAP J2EE on HP-UX
 
552522 - Java Hotspot VM Memory Parameters (hint outdated)
 
534867 - j2ee server on HP-UX unable to create new native thread
 
492222 - SAP Software on UNIX: OS Dependencies 6.20

No comments: