Java Performance Tuning For Beginners PDF
Java Performance Tuning For Beginners PDF
Java Performance Tuning For Beginners PDF
Beginners
Applies to:
SAP NetWeaver Application Server Java for Beginners. For more information, visit the Java homepage.
Summary
This document will guide you to configure the SAP NetWeaver Application Server Java.
Author: D S Radhakrishna
Company: Intelligroup Asia Pvt Limited
Created on: 10 October 2008
Author Bio
Radhakrishna D S has more than 3 and half years of experience. He has good understanding of SAP R3 and
NetWeaver Components. He is currently working for Intelligroup Inc as a Basis Consultant.
Table of Contents
Introduction .........................................................................................................................................................3
Structure of SAP Web Application Server ..........................................................................................................3
Cluster with Multiple SAP Web AS Java Instances............................................................................................4
The Template Configuration Tool .......................................................................................................................5
Tuning the Operating System ...........................................................................................................................10
Configuring J2EE Engine Cluster .....................................................................................................................10
Performance Parameters..................................................................................................................................11
JDK Upgrade ....................................................................................................................................................12
Setting the Java VM Parameters......................................................................................................................12
Heap Size......................................................................................................................................................13
New Generation ............................................................................................................................................14
Permanent Space .........................................................................................................................................14
Tuning the Engine for J2EE Scenarios.............................................................................................................14
SAP NetWeaver Configuration .........................................................................................................................15
Configuring Database Connections..................................................................................................................15
Performance Impact of the Monitoring Infrastructure .......................................................................................15
Thread Dump....................................................................................................................................................16
Symptom-Driven Troubleshooting ....................................................................................................................16
Disclaimer and Liability Notice..........................................................................................................................17
Introduction
J2EE Engine forms the Java basis of Web Application Server. It consists of a Java kernel part, which
provides and manages the runtime environment of all Java-based SAP services and applications, and a
J2EE part to ensure the J2EE compliance of Web Application Server.
I will start with the Web AS architecture and Java cluster and deal with some of the important J2EE
parameters with relevant SAP Notes which will help in tuning the system for better performance.
The individual components and their tasks are briefly in the following:
• TheInternet Communication Manager (ICM) creates contact with the Internet. It can process both
server and client Web requests. It supports the protocols HTTP, HTTPS, and SMTP. SAP Web AS
can act either as a Web server or as a Web client.
• TheABAP dispatcher distributes the requests to the work processes. If all processes are occupied,
the requests are stored in the dispatcher queue.
• TheABAP work processes execute the ABAP code
• Themessage server is used to exchange messages and to balance load in the SAP system.
• In the Java part of SAP Web AS, there are the components Java dispatcher, server process, and
Software Deployment Manager (SDM) as well as the Central Services.
• The Java dispatcher distributes the client requests to the free server processes of the instance.
• The server processes provide the infrastructure in which the J2EE applications run.
• The Central Services form a special Java instance. They provide the basis of communication and
synchronization within a Java cluster.
o The message service administers a list of the dispatchers and the server processes of the
Java cluster
o The enqueue service administers logical locks that are set in a server process by the
executed application program.
• The central instance is another special instance. This runs on a physical server with the Central
Services and the database
(JDI)
Development Infrastructure where DTR and CBS are system with DTR;
CBS.zip . system
with CBS
Engine
on multi-processor servers
on single-processor servers
and UDI
only.zip
The Template Configuration Tool adjusts the VM memory parameters, the number of server processes, and
manager settings such as the number of threads in your SAP Web AS Java instance to the selected
scenario. If services are set to manual start during the standard installation, but are required for the selected
scenario, the Template Configuration Tool sets them to .Start: always.
Note: You must always stop the SAP Web AS instances to use the Template Configuration Tool. Using the
Configuration Tool is part of the installation postprocessing. It must only be used directly after the installation, since
it deletes existing settings. For more information, see SAP Note 739788.
Click next to get the below screen. You have to choose whether you want to apply the template or restore
the configuration using a previous backup.
Clicking on next it will take you to the below screen where you we have to mention the template file which
you can find in the template folder within the template configuration and corresponding instance directory if
there are more than one instance in a system.
Template configuration wizard will come up with the system parameters which are set in the system.
Choose the relevant check box, so that template configuration will act accordingly.
After clicking the next button it will take to the last screen as shown below
Performance Parameters
There are numerous parameters, which can be adjusted with the SAP Web Dispatcher. The documentation
is available at:
help.sap.com/nw04 -> SAP Library -> SAP Netweaver -> SAP NetWeaver Technical Operations
Manual -> Management of the SAP Web Dispatcher
JDK Upgrade
It should be the most actual one from the 1.4 family. J2EE Engine 6.40/7.0 is not supported on 1.3 or 1.5
Java platform. Details can be found in the below OS-specific notes. Refer to note 718901 about changing of
the JDK, see also 731269. Please apply note 754699 after JDK upgrade.
The java parameters have to be set via ConfigTool which is located in the J2EE Engine directory tree under
j2ee/configtool (e.g. C:\usr\sap\C11\JC00\j2ee\configtool). Start the configtool.bat (.sh on unix), select
cluster_data/instance_ID.../server_ID... and make the change in the "Java parameters" field. If you have
more than one server node, you need to apply the change to every server node and also to the dispatcher
node.
After changing the values, click on the disk icon to save the new values and restart the cluster is a must.
Note: It should be the most actual one from the 1.4 family. J2EE Engine 6.40/7.0 is not supported on 1.3 or 1.5 Java
platform. Refer to note 718901 about changing of the JDK, see also 731269 and apply SAP note 754699 after
JDK upgrade.
The three main memory areas of the VM, the young, tenured, and permanent generations differ from one
another because of the data stored in them. The objects that have been newly created by the applications
are stored in the young generation. Objects that have been required for a longer period of time by an
application are automatically moved to the tenured generation.
Objects that are no longer required by the applications are automatically removed from the generation. This
process is known as garbage collection.
Heap Size
For 32 bit platforms SAP recommend to start the server nodes with 1GB
Where by the initial and the maximal heap size should be equal: -Xmx1024m and -Xms1024m
Higher values may cause troubles, for example see notes 736462 and 664607 about Windows DLLs
preventing big java heap. SAP recommends using additional server nodes instead of huge heaps.
For 64 bit platforms (that means not only your OS but also your JDK Supports 64 bit) SAP recommend using
2GB: -Xmx2048m -Xms2048m.
Take into account while planning your productive landscape: for NW 7.0 (04s) There is a general
recommendation to use 64bit systems, see note 996600.
The max heap size (plus max perm size) of all Java server nodes must fit completely into the physical
memory in order to avoid heavy paging on OS level which leads to dip in performance. You must also
consider the space needed for OS and other processes.
New Generation
MaxNewSize to approximately 1/6 of the heap, for example:
• -XX:NewSize=171m -XX:MaxNewSize=171m for 1 GB heap size and
• -XX:NewSize=341m -XX:MaxNewSize=341m for 2 GB heap site
Permanent Space
For 6.40 on 32 bit: -XX:MaxPermSize=192m -XX:PermSize=192m
For 6.40 on 64 bit: -XX:MaxPermSize=384m -XX:PermSize=384m
For 7.0 on 32 bit: -XX:MaxPermSize=256m -XX:PermSize=256m
For 7.0 on 64 bit: -XX:MaxPermSize=512m -XX:PermSize=512m
Remark 1: Be aware of the fact that more permanent space is needed if additional applications are deployed
or the complexity of the applications (roughly speaking number of classes) grows.
Increasing of the heap size or permanent space is harmless on 64 bit systems (given that enough physical
memory is available) however on 32 bit ones (especially Windows) one should take into account limitations
of the virtual address space.
For Garbage Collector options, SoftReferences, to disable canonicalization optimization see 723909
which have complete details to work on the same.
Thread Dump
A java application is hanging, not responding, or consuming too much CPU. If your java application hangs or
it is consuming much CPU even though there is not much traffic, the java application must be analyzed in
more detail. One approach for this is to trigger a dump of all java threads and their call stacks in the VM.
How to trigger a full thread dump depends on the way the J2EE engine is started and on which operating
system the engine runs is completely explained in the note 599539.
Symptom-Driven Troubleshooting
If you face any problem regarding slow response time which leads to performance problems the below link
will be help full in finding the cause for the same.
help.sap.com/nw04 -> SAP Library -> SAP NetWeaver -> SAP NetWeaver Technical Operations Manual ->
Troubleshooting for SAP Web Application Server
Some of the known issues which I came across during projects involved. SAP Notes:
710146 How to change J2EE Engine JVM Settings
1095476 - Information for troubleshooting of the AS Java
823906 Oracle database parameters tuning - EP in NW
940893 Analysis of errors within the startup of J2EE Engine 6.40
763789 Improve Portal Performance by Changing Log Levels
625509 Enterprise Portal hangs with almost 100% CPU usage
861333 Very slow start of the j2ee engine on AIX with 64bit IBM JDK
764215 Problems with big java heap when started via jlaunch.exe
1016241 J2EE Engine hangs because of unsufficient system threads
855213 Deadlock in start up of dispatcher process
742395 Analyzing High CPU usage by the J2EE Engine
599539 J2EE Engine: How to create a full thread dump
743207 Analyzing High CPU usage by the J2EE Engine: Windows
686254 Thread dump from J2EE Engine 6.20 running as Windows service