Professional Documents
Culture Documents
Jurijs Velikanovs
7+ years Oracle DBA, OCP 7/8/8i/9i, OCA 9iAS R2
Topics:
z Introduction
z Usage considerations
z OC4J Internals
z OC4J Troubleshooting
z OC4J Performance tuning
z BC4J
Introduction
Who am I? And what are my responsibilities?
z Who am I?
I am a DBA team leader
I’m neither a Java fan nor a Java Developer nor a Java
Guru
My team has spent a lot of time researching and
struggling to stabilize the production environments
based on OC4J
z Responsibilities
To support production and development environments
To ensure production availability
To troubleshoot production system
To provide all the necessary information to the
developers or support organizations to solve a problem
How were we involved?
OC4JMonitor
PORT: 3001 AJP new req Thread
Connection ApplicationServerThread
Listener Thread
ApplicationServerThread
ApplicationServerThread
ApplicationServerThread
Java native
AJP 1.3 ApplicationServerThread
... ONet
ApplicationServerThread
ApplicationServerThread
Memory Structures
Application objects
Java native
RMI
RMIServer
Server TaskManager VM Periodic Task
3101
PORT: 3101
TaskManager VM Thread VMThread
Periodic Task
VM Thread
Thread
JMSServer
3201
BUT:
z Keep it as simple as possible
z At first you should be sure that the system works
properly in a simple configuration
z Make components as independent as possible
z Don’t use the infrastructure if there is no strong
need for it (i.e. Single-Signon, Discoverer,
Clustering)
Oracle AS Typical Architecture
opmn.xml
httpd.conf server.xml
Apache OHS (c) OC4J JVM
JVM(java)
Child
Child Server
Server
Child Server JMSServer
Child Server JMSServer
JMSServer
Child Server Thread
JMSServer
Child Server Thread
Thread ApplicationServerThread
Child
Child Server
Server Thread
Child
Child
Server
Server ApplicationServerThread
Child Server
Child Server ApplicationServerThread
Child Server ApplicationServerThread DB
Child Server
Child Server
Child Server ApplicationServerThread
PORT: 80, 7780
Child
Child
Child Server
Server
Server ApplicationServerThread
Child Server AJP
HTTP AJP 1.3
PORT: 3001
Child Server
WAN Child Server
Child Server
Child Server
AJP
Connection
Connection
Listener
Child
Child Server
Server Listener OC4JMonitor
Child
Child
Server
Server TaskManager
TaskManager
Child Server OC4JMonitor
Thread TaskManager
Child Server TaskManager
Child Server Thread (dms)
Child Server
Child Server
Child
Child Server Java native
Child Server
Server Java native
VM Periodic Task
VM Thread VMThread
Periodic Task
VM Thread
Thread
RMI
RMIServer
Server Signal Dispatcher Finalizer
PORT: 3101 Signal Dispatcher Finalizer
Suspend Checker Reference
JMSServer Suspend
PORT: 3201
ThreadChecker Reference
Handler
Thread Handler
Installation Considerations
Recommendations Application
Have a dedicated test
environment and verify APP Frame Work
all the changes there
before implementing in BC4J 9.0.3.10.7
production
If you have the
OC4J JDBC
automatic stresstesting c.c.c.x c.c.c.x
scenarios, run them after 9.0.3.1 9.2.0.5
each change in the test
environment JDK c.c.x_x, 1.3.1_15
Monitor the impact of
changes and if the
situation becomes worse OS 2.4.9-e.38enterprise
rollback them
Versions Considerations
z OS
Application
It is important to install the latest
patches from an OS vendor
(Kernel, Network, etc.) APP Frame Work
Usually the patches can be
rollbacked easily BC4J 9.0.3.10.7
The change of OS main release
requires more testing and efforts
than patching
z JDK OC4J JDBC
c.c.c.x c.c.c.x
Install the latest versions of JDK 9.0.3.1 9.2.0.5
within c.c. boundaries
Use the JDK from Sun
ww.JavaSoft.com JDK c.c.x_x, 1.3.1_15
To install it replace the OH/jdk
directory. These changes can be
rollbacked easily OS 2.4.9-e.38enterprise
The change of c.c. version
requires the Development
involvement and more testing
Versions Considerations
z JDBC
Install the latest version of JDBC Application
within c.c.c. version
To install it replace OH/jdbc APP Frame Work
directory. These changes can be
rollbacked easily
It requires the minimal BC4J 9.0.3.10.7
functionality testing
z OC4J
Can be easily upgraded within a
c.c.c. version boundaries OC4J JDBC
c.c.c.x c.c.c.x
It requires the minimal
9.0.3.1 9.2.0.5
functionality testing
Follow the patch installation
instructions (9iAS 9.0.3.1) JDK c.c.x_x, 1.3.1_15
There are 50+ one-off patches
(*.class)
The change of c.c.c. version
requires the Development OS 2.4.9-e.38enterprise
involvement and more testing
Versions Considerations
z BC4J Application
A BC4J version sets the
requirements for OC4J version APP Frame Work
It can’t be changed without
Development involvement BC4J 9.0.3.10.7
even within x.x.x.x. version
boundaries
Often there are needs for OC4J JDBC
application changes c.c.c.x c.c.c.x
9.0.3.1 9.2.0.5
It requires a lot of testing
New version can have negative
JDK c.c.x_x, 1.3.1_15
impact to your application
The change of c.c.c. version
requires more application code OS 2.4.9-e.38enterprise
changes, testing, and other
efforts
Versions Considerations
OC4JMonitor
new req Thread
PORT: 3001
AJP
Connection ApplicationServerThread
Listener Thread
ApplicationServerThread
ApplicationServerThread
ApplicationServerThread
Java native
AJP 1.3 ApplicationServerThread
... ONet
ApplicationServerThread
ApplicationServerThread
Memory Structures
Application objects
Java native
RMI
RMIServer
Server TaskManager VM Periodic Task
3101
PORT: 3101
TaskManager VM Thread VMThread
Periodic Task
VM Thread
Thread
JMSServer
3201
z TaskManager
Responsible for a periodic tasks executing (housekeeping)
server.http.SessionTimeoutTask (drops expired session)
server.ApplicationServerTask (clear expired threads)
sql.DriverManagerXADataSource
…
You can set an executing frequency in server.xml file
taskmanager-granularity=1000 (default 1 sec)
Use the dmstool to monitor the statistics of the process
dmstool -table oc4j_task
z ApplicationServerThreads (Global Thread Pool)
Execute users requests, run an application code, communicate
with the Apache processes and the database
Initial count of the processes can be set in server.xml file
global-thread-pool min=“200" max="200" queue="20“
OC4J Troubleshooting
Classification of Problem Areas
OC4J
JVM(java)
4.
PORT: 3001
AJP
JMSServer
JMSServer
Connection
Listener ApplicationServerThread
New Request
ApplicationServerThread
as
Apache
sig
n ApplicationServerThread
ApplicationServerThread
ApplicationServerThread
1.
ApplicationServerThread
TaskManager
3. DB
2. ApplicationServerThread
ApplicationServerThread
ApplicationServerThread
JDK
OS
======== PM ========
PM requests processed: 5
PROCESS TABLE
UID PID FLAGS TYPE STATUS REF HTTP AJP RMI JMS
---------- ----- -------- ------- ------- ------ ----- ----- ----- -----
456236 13512 00000040 OC4J Alive 1 0 3003 3104 3204
390700 13511 00000040 OC4J Alive 1 0 3002 3103 3203
521772 15874 00000040 OC4J Alive 1 0 3001 3102 3202
259628 13415 00000040 OC4J Alive 1 0 3000 3101 3201
194092 13338 00000040 Apache Alive 1 7780 0 0 0
128556 13281 00000040 Generic Alive 1 0 0 0 0
How to get a “Full thread dump”?
z Waiting on monitor
In most of cases it is an idle state of the thread. The thread is waiting
for a task to execute or voluntary sleeps
All the available ApplicationServerThreads are in this state
z Runnable
The thread is executing application code or reading from the socket
All listeners must be in this state
z Waiting for monitor entry
Waiting to lock an object (other thread is holding the lock). This
happens if two or more threads are trying to execute synchronized java
code
None of threads must be in this state for a long time
If the system thread stays in this state for a long time you are in trouble
If many threads are in this state you have the situation of serialization
Threads Examples
1. OC4JMonitorThread is waiting for a work. Usual state for most of the
threads
"OC4JMonitorThread" daemon prio=1 tid=0x679a3518 nid=0x573 waiting on monitor [0xa53ff000..0xa53ff89c]
at java.lang.Object.wait(Native Method)
at oracle.ons.NotificationQueue.internalDequeue(NotificationQueue.java:251)
at oracle.ons.NotificationQueue.dequeue(NotificationQueue.java:224)
at oracle.ons.Subscriber.receive(Subscriber.java:136)
at com.evermind.server.OC4JMonitorThread.run(OC4JMonitorThread.java:419)
at java.lang.Thread.run(Thread.java:479)
z -XX:+JavaMonitorsInStackTrace (opmn.xml)
<java-option value="-server -Xms512M -Xmx512M -verbose:gc -XX:+JavaMonitorsInStackTrace"/>
PORT: 3001
AJP
JMSServer
JMSServer
Connection
Listener ApplicationServerThread
New Request
ApplicationServerThread
as
Apache
sig
n ApplicationServerThread
ApplicationServerThread
ApplicationServerThread
1.
ApplicationServerThread
TaskManager
3. DB
2. ApplicationServerThread
ApplicationServerThread
ApplicationServerThread
JDK
OS
z OC4J default-web-access.log
Located at
OH/ j2ee/PANDA/log/PANDA_default_island_1/default-web-access.log
z System wide:
vmstat, iostat, uptime, pstree
1107387907360:ThrP[50] ThrQ[0]
1107387907360:CxP[20] CxQ[0] - WebC[0] RmiC[0]
AJP: Input request length is: 1
AJP: AJPOutputStream::write() of 1
AJP: AJPOutputStream::writeChunk(): 1
1107387908370:ThrP[50] ThrQ[0]
1107387908370:CxP[20] CxQ[0] - WebC[0] RmiC[0]
z Some of available categories are : ajp, http, jms, rmi, jdbc
Documentation and Internet
………………………………………………………………..
Metalink Patches
Set min to high value. It allows OC4J not to create the additional
threads on the fly
You don’t have to take care on max, keepAlive and queue parameters then
OC4J doesn’t need to manage queue
debug="true" – Allows to see statistics in the OC4J process
standard output file
It is useful as troubleshooting information as well. Record appears in the output file at
the end of each Task manager cycle.
<PANDA.default_island.1>
1107390315893:ThrP[100] ThrQ[0]
1107390315893:CxP[100] CxQ[0] - WebC[0] RmiC[0]
1107390316903:ThrP[100] ThrQ[0]
1107390316903:CxP[100] CxQ[0] - WebC[0] RmiC[0]
...
Our Findings (OC4J Processes)
OH/opmn/conf/opmn.xml
<oc4j …
<java-option value="-server -Xms512M -Xmx512M"/>
</oc4j>
z Set max=min
JVM doesn’t need to manage memory allocation dynamically
You have reserved memory on the server
z Java Garbage collector
There is a lot of information around
http://developers.sun.com/techtopics/mobility/midp/articles/garbagecollection2/
http://www.cons.org/cmucl/doc/gc-tuning.html
-verbose:gc
z Java Profilers
Add significant overhead to be used in production environments
Extremely useful in test/dev environments for troubleshooting
Our Findings (Memory)
JSP Processing
mod_oc4j Servlet Processing
DB
handle
Process E
Handle E
Handle B
Handle E
Request E
mod_perl
Recive mod_php
...
DMS-client
DMS.JAR (java)
statistics reflecting
Response Time Breakdown Example
$ dmstool -table ohs_server | grep time
.../Apache/connection.time 48123608767 usecs
.../Apache/request.time 15916131942 usecs
.../Apache/handle.time 15913988395 usecs
rhoracle.voava.lv*J2EE01-/u01/app/oracle/product/J2EE01/Apache/Apache/conf
$
$ dmstool -table ohs_module | grep time | sort -k2n | tail -2
.../Apache/Modules/mod_dms.c/handle.time 8081655 usecs
.../Apache/Modules/mod_oc4j.c/handle.time 15905072698 usecs
$
$ dmstool -table oc4j_jspExec | grep time
.../oc4j/PANDA/WEBs/PANDA/JSPs/processRequest.time 17 563 793 msecs
$
$ dmstool -table "oc4j_jsp(threadsafe=true)" | grep time | sort -k2n | tail -5
.../oc4j/PANDA/WEBs/PANDA/JSPs/NSK/NSK003/NS0285F_searchForm.jsp/service.time 1 072 570 msecs
.../oc4j/PANDA/WEBs/PANDA/JSPs/SKD/d001/D2261F_PersonsBrowse.jsp/service.time 1 407 663 msecs
.../oc4j/PANDA/WEBs/PANDA/JSPs/NSK/NSK003/NS0291F_Browse.jsp/service.time 2 942 655 msecs
.../oc4j/PANDA/WEBs/PANDA/JSPs/SKD/d001/D2261F_Edit.jsp/service.time 3 151 184 msecs
.../oc4j/PANDA/WEBs/PANDA/JSPs/SKD/d001/D2260F_Browse.jsp/service.time 4 847 408 msecs
rhoracle.voava.lv*J2EE01-/u01/app/oracle/product/J2EE01/Apache/Apache/conf
$
DMS Sensors Classification
Snap
Id Snap Started
------- -------------------
530 2005-02-03 12:33:26
531 2005-02-03 13:03:24
532 2005-02-03 13:33:27
549 2005-02-03 14:03:32
SYS:PROD>
Monitor All the Tiers of the System
z AskTom.oracle.com
http://asktom.oracle.com/pls/ask/f?p=4950:8:16675873436862412624::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:12836314571537
…
Another example is asktom.oracle.com. Just go there and click on any article
from the home page. You'll see a URL similar to:
http://asktom.oracle.com/pls/ask/f?p=...::NO::
If you simply type over that URL and replace the word NO with YES - you'll see
the same page but with lots and lots of state/timing information dumped into it.
…
BC4J
OC4J Internals & BC4J
ONS
Thread
OC4JMonitor
new req Thread
PORT: 3001
AJP
Connection ApplicationServerThread
Listener Thread
ApplicationServerThread
ApplicationServerThread
ApplicationServerThread
Java native
AJP 1.3 ApplicationServerThread
... ONet
ApplicationServerThread
ApplicationServerThread
Memory Structures
Java native
RMI
RMIServer
Server TaskManager VM Periodic Task
3101
PORT: 3101
TaskManager VM Thread VMThread
Periodic Task
VM Thread
Thread
JMSServer
3201
z Introduction
z Usage considerations
z OC4J Internals
z OC4J Troubleshooting
z OC4J Performance tuning
z BC4J
Q&A