Documentos de Académico
Documentos de Profesional
Documentos de Cultura
DB2 WebSphere
Integration Best Practice
Peter Shum
IBM Toronto Laboratory
In many DB2 shops, more and more solutions are based on WebSphere
Application Server and yet there is a limited understanding on how
WebSphere and DB2 interact with each other beyond just the SQL. In
this session, we'll walk through the architecture of WebSphere, the flow
of a query, and then identify the best practice for monitoring,
configuration, and application when interfacing with DB2.
Agenda
Architecture Overview
Performance Monitoring Best Practice
Configuration Best Practice
Application Best Practice
Miscellaneous
Whats Coming
Disclaimer
The information in this presentation concerns new products that IBM has
announced. The specification of some of the features described in this
presentation may change before the General Availability date of these products.
Any discussion of non-IBM products is based upon information which has been
publicly available and is subject to change
REFERENCES IN THIS PUBLICATION TO IBM PRODUCTS,
PROGRAMS, OR SERVICES DOES NOT IMPLY THAT IBM INTENDS TO
MAKE THESE AVAILABLE IN ALL COUNTRIES IN WHICH IBM OPERATES
IBM MAY HAVE PATENTS OR PENDING PATENT APPLICATIONS
COVERING SUBJECT MATTER IN THIS DOCUMENT. THE FURNISHING OF
THIS DOCUMENT DOES NOT IMPLY GIVING LICENSE TO THESE PATENTS.
TRADEMARKS AND REGISTERED TRADEMARKS ARE THE PROPERTY
OF THEIR RESPECTIVE COMPANIES
Architecture Overview
Acknowledgment: Diagrams in this section were taken from the DB2 UDB/WebSphere
Application Server V6 Performance Tuning and Operations Workshop, by ITSO
4
J2EE Architecture
Note the 4 components: client, web container, EJB container, and the
datasource (i.e. database).
The J2EE platform specification describes the run-time environment for a J2EE
application. This environment includes application components, containers, and
resource manager drivers. The elements of this environment communicate with
a specified set of standard services.
J2SE Java 2 Platform, Standard Edition provides a complete environment for
applications development on desktops and servers and for deployment in
embedded environments. It also serves as the foundation for the Java 2
Platform, Enterprise Edition (J2EE) and Java Web Services.
RMI-IIOP Remote Method Invocation Internet Inter-Orb Protocol delivers
Common Object Request Broker Architecture (CORBA) distributed computing
capabilities to the Java 2 platform.
JDBC Java Data Base Connectivity is an API (included in both J2SE and J2EE
releases) that provides cross-DBMS connectivity to a wide range of SQL
databases and access to other tabular data sources, such as spreadsheets or
flat files
JMS Java Message Service provides a standard Java-based interface to the
message services of a Message-Oriented-Middleware (MOM) of some other
provider.
JNDI Java Naming and Directory Interface is part of the Java platform,
providing applications based on Java technology with a unified interface to
multiple naming and directory services
JAF Java Agent Framework builds upon the Java Beans model by supplying a
b
f f iliti d i
dt
k
td
l
t d
t
W ebcontainer
Inbound chain(
Admin
application
HTTP(s)
Adm in
UI
Scripting
client
SOAP or
RMI/IIOP
EJB container
Client container
RMI/IIOP
Java client
Admin service
HTTP(s)
W ebSphere
plug-in
application (EAR)
HTTP server
UDDI registry
W eb container
W eb
browser
client
JCA services
Config
repository
(XML files)
Application
Database
Msg
Queue
m anages
m anaged by external
provider
(W ebSphere MQ)
JMS, MQ
Messaging engines
Msg
Queue
SOAP/HTTP
W eb Service
Provider or
Gateway
In WebSphere, you still have the 4 major components of client, web container,
EJB container, and databasource. However, many of the services are shared
by both the web container and EJB container. WAS components for standalone
are:
Node - Logical grouping of server processes managed by WebSphere that
share a common configuration and operational control -- not necesarily a
machine
Application server (instance) - One JVM process
Web container and EJB container - Can be separated but is not recommended
due to negative performance impact
JNDI and Security services
Administrative service - One in each JVM. Manipulates application server
configuration
Administrative Console - Web administration interface. Connected through an
admin application to the Admin service
Configuration repository - No database, but XML file. Contains configuration
information
Web server and Web server plug-in - Accepts requests from clients. If rule
describes, forwards request to application server plugin-cfg.xml
Embedded HTTP transport - Located in Web container. Receives requests
from plug-in. HTTP/HTTPS communication with plug-in. Forwards requests to
servlets
Embedded Messaging (JMS) Server - Point-to-point and publish/subscribe
i
i
N t i W bS h
E
HTTP(s)
Admin
application
Scripting
client
Admin Service
Master
repository
(file)
SOAP or
RMI/IIOP
Node
Node Agent
Admin Service
Application Server
Config
repository
(file)
Web container
Webcontainer
Inbound
chain(s)
EJB container
Session
Database
Admin service
HTTP(s)
WebSphere
plug-in
UDDI registry
HTTP server
SOAP
(Web
Services)
engine
application (EAR)
Web
browser
client
Application
Database
EJB
HTML
JSP
11
Enterprise
Java Bean
10b
14
13
Web Server
3
Data
Sources
EJB Container
12
10a
Servlet 6
7
8b
JNDI
8a
plug-in 4
DB2
application
database
Even though the full architecture of a J2EE system could be quite complicated,
we could still simplify the basic and typical query flow to make it easier to
understand how it works for database requests.
1. A Web client requests a URL in the browser (input page).
2. The request is routed to the Web server over the Internet.
3. The Web server immediately passes the request to the WebSphere plug-in.
All requests go to the WebSphere plug-in first.
4. WebSphere plug-in examines the URL, verifies the list of hostname aliases
from which it will accept traffic based on the virtual host information, and
chooses a server to handle the request.
5. A stream is created. A stream is a connection to the Web container. It is
possible to maintain a connection (stream) over a number of requests. The
Web container receives the request and based on the URL, dispatches it to
the proper servlet.
6. If the servlet class is not loaded, the dynamic class loader loads the servlet.
Servlet init(), then doGet() or doPost().
7. JNDI is now used for lookup of either datasources or EJBs required by the
servlet. Depending upon whether a datasource is specified or an EJB is
requested,the JNDI will direct the servlet:
8. a) To the corresponding database, and get a connection from its connection
pool in the case of a datasource
b) To the corresponding EJB container, which then instantiates the EJB,
when an EJB is requested
EJB Container
Command cache
Java Object cache
JNDI cache
EJB caching
Database
Buffer Pool
Catalog Cache
Package Cache
9
Listener
Agent Pool
LA
Dispatcher
MAXAPPLS
MAXAGENTS
MAX_COORDGENTS
MAX_POOLAGENTS
CA
SA
Applheapsz
Appgroup_m em_sz
Groupheap_ratio
Appl_ctl_heap_sz
Sortheap
Stm theap
Stat_heap_sz
Agent_stack_sz
Query_heap_sz
dbheap
MAXCAGENTS
appl heap
sort heap
RDS
stmt heap
stat heap
catalog cache
catalogcache_sz
pkcachesz
package cache
agent stack
DMS
query heap
Sort
DPS Acquire
lock
locklist
locklist
MAXLOCKS
Table/Index Manager
Sort
over flow
sortheap
sheapthres_shr
sheapthres
DPS Acquire
logging
logbuffer
MINCO MMIT
logbufsz
Prefetcher
queue
LEGEND
Buffer Pool
CHNGPGS_THRESH
NUM_IOSERVERS
NUM_IOCLEANERS
SOFTMAX
Tem p
10
Obtain
token
from DBM
Aguire memory +
token
Index
Data
Log
LA
CA
SA
RDS
DMS
DPS
BPM
10
11
11
3. Concurrent Requests
HTTP
Web Server
8. CPU
9. I/O
10. Paging
HTTP
Web Container
EJB Container
Data Source
ORB
5. ORB Thread Pool
JDBC
IIOP
DB
7. Java Virtual Machine Memory
8. CPU
9. I/O
10. Paging
12
8. CPU
9. I/O
10. Paging
12
Web Applications
Servlet/JSP response time
Servlet/JSP requests
Message EJBs
Trade
Trade
Servlets
Trade
Session
EJB
Servlets
Joe
in action!
Web
Client
Workload Management
# of requests
# of updates
Dynamic Cache
Memory cache size
# of hits/misses
Trade
Trade
Servlets
JSPs
Web Container
Web Services
Client
JAX/RPC
SOAP
Servlet
Auditor
Client
TradeAction
Java Transactions
# active transactions
Avg duration
System Data
CPU Utilization
Memory usage
WebSphere
Command
Beans
TradeServices
PMI Data
TradeBroker
Topic
MDB
Streamer
MDB
Queue
EJB Module
EJB response time
EJB requests
Trade
Database
EJB Container
Web Services
Trade
Direct
JDBC
JVM
Message
Server
Pub/Sub
JVM Memory
Free memory
# of garbage collection calls (JVMPI)
Web Services
# of loaded web services
# of requests delivered/processed
13
Thread Pools
Web container and ORB
Active threads
% pool maxed
IMS, CICS
13
System Data
CPU Utilization
Memory usage
Dynamic Cache
Memory cache size
# of hits/misses
Web Applications
Servlet/JSP response time
Servlet/JSP requests
Message EJBs
Trade
Trade
Session
EJB
Trade
Trade
Servlets
JSPs
Web Container
Web Services
Client
(JAX/RPC)
TradeAction
Joe
in action!
Web
Client
WebSphere
Command
Beans
JAX/RPC
SOAP
Servlet
Auditor
Client
Web Services
TradeServices
Trade
Servlets
Servlets
Java Transactions
# active transactions
Avg duration
Workload Management
# of requests
# of updates
TradeBroker
Topic
MDB
Streamer
MDB
Queue
Trade
Database
EJB Container
Trade
Direct
JDBC
JVM
Message
Server
Pub/Sub
JVM Memory
Free memory
# of garbage collection calls (JVMPI)
Web Services
# of loaded web services
# of requests delivered/processed
Available as of 5.0
Available as of 5.0.2
Available as of 6.0
14
Thread Pools
Web container and ORB
Active threads
% pool maxed
Object Request Broker (ORB)
Object reference lookup time
# of requests
HA Manager
# of local groups
# of bulletin-board subjects
For your reference a subset of the key ones and in which release they
become availalble.
14
15
16
This chart shows a view from the Tivoli Performance Viewer which
displays the PMI data- this tool ships as part of WebSphere Application
Server. For those of you who used WAS 4.0, remember that Tivoli
Performance Viewer is the new name for Resource Analyzer. You can
view the data in tabular form or in graphical form. On the graph you can
also select which counters you want displayed. This particular view is
showing that there is a large number of discards from the prepared
statement cache. If the cache were set to a larger size, you should see
the discard rate reduced and some performance gains as a result.
16
17
For details, go to
http://publib.boulder.ibm.com/infocenter/wasinfo/v6r0/index.jsp?topic=/co
m.ibm.websphere.express.doc/info/exp/ae/tprf_enablingtpvadvisor.html
For a demo, go to
http://publib.boulder.ibm.com/infocenter/ieduasst/v1r1m0/topic/com.ibm.i
ea.was_v6/was/6.0/Performance/WASv6_TPVPerformanceAdvisor.viewl
et/WASv6_TPVPerformanceAdvisor_viewlet_swf.html?dmuid=20061227
195912256394
This is a screen shot from the Performance Advisor in Tivoli performance
viewer. The section at the top is a blown up version from the screen shot
underneath. The advisor was run against an internal application, and as
you can see we received advice on how to set the configuration for
many of our Websphere parameters. Note the highlighted message
when you could be click on that msg.
[This particular customer doesnt have any simple config problems; all of
his warnings are of a 2a type]
Tuning strategy
17
18
You get more details. This message specifically tells you that the rate of
discards from the preapred statement cach is high and suggests to the
user that the size of the cache be increased.
18
19
19
bufferpools
all
bufferpools
applications on <database>
tables
S
locks
database
tablespaces
Log usage
Dynamic SQL
applications
SQL stmt
activity
all
Application
state
Pkg/Sect/Cat
cache
Rows
read/selected
CPU utilization
Agents
Lock summary
database manager
Sorts
Lock detail
Memory pools
databases
Tables
how to
get it
so
m an
d
us e pr
th efu ett
in l y
gs
Tablespaces
S
P
dynamic sql
A
P
Overhead: 3-5% overhead for most settings, 10% for all including SQL snapshot,
more if system is stressed (A always collected S collected only when monitor switch is ON
P collected when switch is ON, partially collected when switch is OFF. )
20
This chart gives us a summary of what we can get (across the top) and
how to get it (down the left side.)
An A in the chart means the indicated information is always collected,
regardless of the state of monitor switches.
P means the data is partially collected (but to get all the information, you
need to have the appropriate switch turned on)
S means that the data is only available if the switch is on.
The green ellipses indicate especially useful areas, and are what were
going to focus on in the following slides.
20
See
http://publib.boulder.ibm.com/infocenter/db2luw/v8/index.jsp?topic=/com.ibm.db
2.udb.doc/ad/rjvjdb2o.htm
21
22
WebSphere5-Wrkstn
WebSphere5-Appl
22
Via the Admin Console: Troubleshooting > Logs and Trace > pick the
server > Change log detail level > Configuration or Run time > Trace
Specification
23
See
http://publib.boulder.ibm.com/infocenter/wasinfo/v6r0/index.jsp?topic=/com.ibm.
websphere.express.doc/info/exp/ae/rdat_impclientinfo.html
23
24
See
http://publib.boulder.ibm.com/infocenter/wasinfo/v6r0/index.jsp?topic=/com.ibm.
websphere.express.doc/info/exp/ae/rdat_impclientinfo.html
24
Native.log
Web
Container
JDBC
Drivers
browser
1b+
1b
Components (2+3)
EJB
Container
DB2
HTTP
Server
Data
Provider
Java
App
1c
Application
Server
DB2 trace
2003 IBM Corporation
25
26
26
Go to Troubleshooting > Logs and Trace > pick the server >
Diagnostic Trace > Trace Specification:
Specify RRA=all=enabled:WAS.database=all=enabled
Notice here that you specify two trace strings separated by ':', one for
the WebSphere Application Server resource adaptor, and one for the
database (JDBC driver) since
27
See the following articles for more details on DB2 JDBC drivers and
tracing
http://www.ibm.com/developerworks/db2/library/techarticle/dm0512kokkat/
http://www.ibm.com/developerworks/db2/library/techarticle/dm0506fechner/
27
28
29
30
30
Configuration
Best Practice
31
31
General
For WebSphere
Do NOT use DriverManager when developing Websphere
applications
use DataSource, JNDI lookups, and datasource reference
32
Network
HTTP
100
Server
Requests
(MaxClients
=75)
Browser
MaxClients for UNIX
ThreadsPerChild for Windows
75
Requests
Web
50
Container
(MaxThreads Requests Data Source
(MaxCon=25)
=50)
25
Database
Connection pool
EJB
Container
(MaxThreads
=50)
ORB thread pool maximum size
EJB Client
33
33
For WebSphere:
HTTP Servers MaxClient
> App Servers MaxThread
> Data Sources MaxCon
For DB2:
maxagent > sum of MaxCon from all WAS nodes
maxappl >= 1.2 to 2x maxagent (to account for indoubts)
num_poolagents > sum of MinCon from all WAS nodes
In general do not enable concentrator unless the WebSphere nodes have
many idle connections and DB2 is memory bound
Use WebSpheres TPV and DB2s Get Snapshot for Database to monitor
and adjust
34
MAXAGENTS
The maximum number of physical DB2 server agents
Set this high enough to handle maximum of all WAS connections
MAXAPPLS
The maximum number of concurrent applications that can be connected to a database
NUM_INITAGENT
Number of agents started when DB2 instance is started
NUM_POOLAGENTS
Specifies maximum size of the server agent pool
34
35
35
XA Transaction Optimization
36
36
JMS
A message-driven bean (MDB) is an enterprise bean that
allows J2EE applications to process messages
asynchronously.
Acts as a JMS message listener, The messages may be sent by any J2EE
component--an application client, another enterprise bean, or a Web
component--or by a JMS application or system that does not use J2EE
technology.
37
JMS
Data store Performance tuning
Sufficiently increase the JDBC connection pool to cope with peak
loads
Place database logs on a fast RAID array to reduce the write latency
Consider putting the SIBxxx tables into a tablespace with 32KB pages
Adjust the column width of the VARCHAR column to 32032 bytes.
38
Choose DB2 instead of FileStore (default in WAS 6.1) for JMS data, and
then choose 1-phase JMS optimization
38
Session Database
Application-related
Enable session persistence (java.io.Serializable)
Reduce size of the session object
Invalidate unneeded sessions
System-related
Use larger DB2 page size
Tune session cache size
Create additional application server instances
Increase available memory
Tune session timeout interval
Consider using multi-row session in database persistence
Tune session database connection pool
Tune the database as usual
39
39
40
40
41
41
42
42
Application
Best Practice
43
43
Use the following Statement methods for creating, executing, and removing a
batch of SQL updates:
addBatch
executeBatch
clearBatch
44
45
TRANSACTION_SERIALIZABLE
Repeatable Read
(RR)
TRANSACTION_REPEATABLE_READ
Read Stability
(RS)
TRANSACTION_READ_COMMITTED
Cursor Stability
(CS)
TRANSACTION_READ_UNCOMMITTED
See http://www-1.ibm.com/support/docview.wss?rs=180&uid=swg21224492 on
how to change the default isolation level with difference methods.
46
47
47
48
48
49
49
50
50
Resources
51
51
Additional Resources
http://www.redbooks.ibm.com
Best Practices for High-Volume Web Sites
DB2 UDB/WebSphere Performance Tuning Guide (and ITSO course)
IBM WebSphere V6.0 Performance, Scalability, and High Availability WebSphere
Handbook (and ITSO course)
WebSphere Version 6 Application Development Handbook
52
http://www.ibm.com/software/webservers/appserv/performance.html
Performance guides includes papers describing how to maximize performance
Redbooks
www.ibm.com/software/support/einfo.html
http://www.ibm.com/software/webservers/appserv/infocenter.html
WebSphere Application Server V6 Tuning Guide
52
Session F13
Peter Shum
IBM Toronto Laboratory
shum@ca.ibm.com
53
53