You've reached the end of your free preview.
Want to read all 388 pages?
Unformatted text preview: Front cover DB2 UDB/WebSphere
Performance Tuning Guide
Overview of DB2 UDB and WebSphere
Application Server architectures
Best practices in tuning a DB2
UDB / WebSphere environment
Problem determination
scenarios Nagraj Alur
Amy Falos
Ada Lau
Svante Lindquist
Monzy Varghese ibm.com/redbooks International Technical Support Organization
DB2 UDB/WebSphere Performance Tuning Guide
March 2003 SG24-6417-01 Take Note! Before using this information and the product it supports, be sure to read the
general information in “Notices” on page xv. Second Edition (March 2003)
This edition applies to IBM WebSphere Application Server V4.0.5, and IBM DB2 Universal
Database V8.1, for use with IBM AIX 4.3.3 and Windows 2000 operating systems.
Comments may be addressed to:
IBM Corporation, International Technical Support Organization
Dept. QXXE Building 80-E2
650 Harry Road
San Jose, California 95120-6099
When you send information to IBM, you grant IBM a non-exclusive right to use or distribute the
information in any way it believes appropriate without incurring any obligation to you.
© Copyright International Business Machines Corporation 2002, 2003. All rights reserved.
Note to U.S Government Users – Documentation related to restricted rights – Use, duplication or disclosure is subject to
restrictions set forth in GSA ADP Schedule Contract with IBM Corp. Contents
Figures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vii
Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi
Examples. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii
Notices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv
Trademarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvi
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii
The team that wrote this redbook . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii
Notice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxi
Comments welcome . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxi
Summary of changes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxiii
March 2003, Second Edition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxiii
Chapter 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1 e-business imperatives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2 e-business applications and their workload profiles . . . . . . . . . . . . . . . . . . 4
1.2.1 Publish and subscribe . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.2.2 Online shopping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.2.3 Customer self-service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.2.4 Online trading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.2.5 Business-to-business . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.3 e-business infrastructure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.4 IBM Application Framework for e-business . . . . . . . . . . . . . . . . . . . . . . . . . 9
1.5 Topology selection criteria. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Chapter 2. Overview of WebSphere Application Server V4.0 . . . . . . . . . . 13
2.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.2 J2EE overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.3 WebSphere Application Server architecture overview . . . . . . . . . . . . . . . 16
2.3.1 Clients . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
2.3.2 Web Server(s) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
2.3.3 WebSphere Application Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
2.4 WebSphere application model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
2.5 Session management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
2.5.1 Choosing a session tracking mechanism . . . . . . . . . . . . . . . . . . . . . 30 © Copyright IBM Corp. 2003 iii 2.5.2 Server affinity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
2.5.3 WebSphere Session Manager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
2.6 Typical application flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
2.7 WebSphere Queuing Network. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
2.8 Tuning WebSphere Application Server . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
2.9 Application tuning considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
2.9.1 Do not store large object graphs in HttpSession . . . . . . . . . . . . . . . . 44
2.9.2 Release HttpSessions when finished . . . . . . . . . . . . . . . . . . . . . . . . 46
2.9.3 JSP considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
2.9.4 Do not use SingleThreadModel. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
2.9.5 Minimize synchronization in servlets . . . . . . . . . . . . . . . . . . . . . . . . . 48
2.9.6 Use the HttpServlet Init method judiciously. . . . . . . . . . . . . . . . . . . . 50
2.9.7 Avoid String concatenation “+=” . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
2.9.8 Minimize uses of System.out.println . . . . . . . . . . . . . . . . . . . . . . . . . 52
2.9.9 Access EJB entity beans from EJB session beans . . . . . . . . . . . . . . 53
2.9.10 Reuse EJB homes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
2.9.11 Use JDBC connection pooling . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
2.9.12 Reuse datasources for JDBC connections . . . . . . . . . . . . . . . . . . . 56
2.9.13 Release JDBC resources when done . . . . . . . . . . . . . . . . . . . . . . . 58
2.9.14 Use Read-Only methods where appropriate . . . . . . . . . . . . . . . . . . 59
2.9.15 Choose the minimal isolation level that is appropriate . . . . . . . . . . 59
2.9.16 EJBs and servlets — same JVM — “No Local Copies” . . . . . . . . . 59
2.9.17 Remove stateful session beans when finished . . . . . . . . . . . . . . . . 61
2.9.18 Avoid using Beans.instantiate() to create new bean instances . . . . 62
2.9.19 Ensure that session objects are serializable . . . . . . . . . . . . . . . . . . 63
2.10 System tuning considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
2.10.1 WebSphere Application Server queues considerations . . . . . . . . . 64
2.10.2 WebSphere Application Server JVM memory considerations. . . . . 74
2.10.3 Other considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
2.11 Monitoring and tuning tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
2.11.1 PMI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
2.11.2 Resource Analyzer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
2.11.3 Performance monitoring servlet . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
2.11.4 Logs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
2.11.5 Traces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
2.11.6 Log Analyzer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
2.11.7 JVMPI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
2.11.8 Performance tuner wizard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
Chapter 3. Overview of DB2 UDB 8 . . .
3.1 Introduction . . . . . . . . . . . . . . . . . . . .
3.2 DB2 architecture overview . . . . . . . .
3.2.1 DB2 agents . . . . . . . . . . . . . . . . iv DB2 UDB/WebSphere Application Tuning Guide .......
.......
.......
....... ......
......
......
...... .......
.......
.......
....... ......
......
......
...... ..
..
..
.. 97
98
99
99 3.2.2 Buffer pools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
3.2.3 Block based buffer pools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
3.2.4 Prefetchers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
3.2.5 Page cleaners . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
3.2.6 Logs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
3.2.7 Deadlock detector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
3.2.8 Disks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
3.2.9 Threading of Java UDFs and stored procedures . . . . . . . . . . . . . . 106
3.3 Tuning DB2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
3.4 Application tuning considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
3.4.1 Database design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
3.4.2 Efficient SQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
3.4.3 Concurrency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
3.4.4 Runstats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
3.5 System tuning considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
3.5.1 DB2 memory utilization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
3.5.2 DB2 64-bit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
3.5.3 Configuration parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
3.6 Monitoring and tuning tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
3.7 Problem diagnosis introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
Chapter 4. WebSphere Application Server and DB2 UDB performance 147
4.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
4.2 Connection pool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
4.2.1 Detailed description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
4.2.2 Best practices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
4.3 Prepared statement cache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
4.3.1 Detailed description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172
4.3.2 Best practices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178
4.4 Session database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
4.4.1 Detailed description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
4.4.2 Best practices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
4.5 Enterprise Java Beans . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209
4.5.1 EJB overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209
4.5.2 EJB performance considerations . . . . . . . . . . . . . . . . . . . . . . . . . . 216
Chapter 5. Problem determination scenarios . . . . . . . . . . . . . . . . . . . . . .
5.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.2 Exception events scenarios. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.2.1 Connection pool size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.2.2 Concurrency issues. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.2.3 Non-serializable objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.3 Routine monitoring scenarios . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Contents 217
218
219
222
251
301
312 v 5.3.1
5.3.2
5.3.3
5.3.4 Determining average session object size . . . . . . . . . . . . . . . . . . . . 314
100K session object size with persistence . . . . . . . . . . . . . . . . . . . 315
100K session object size with local caching . . . . . . . . . . . . . . . . . . 320
30K session object size. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325 Appendix A. Sample applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331
A.1 Trade 2 application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332
A.2 PiggyBank application. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333
A.3 WebSphere Performance Tools (WPT) . . . . . . . . . . . . . . . . . . . . . . . . . 334
Appendix B. Sample scripts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335
B.1 Connection close servlet. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336
B.2 Large session object servlet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337
B.3 SessionInspectServlet.jsp. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 339
Abbreviations and acronyms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345
Related publications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347
IBM Redbooks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347
Other resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347
Referenced Web sites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348
How to get IBM Redbooks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349
IBM Redbooks collections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351 vi DB2 UDB/WebSphere Application Tuning Guide Figures
1-1
1-2
1-3
2-1
2-2
2-3
2-4
2-5
2-6
2-7
2-8
2-9
2-10
2-11
2-12
2-13
2-14
2-15
2-16
2-17
2-18
2-19
2-20
2-21
2-22
2-23
2-24
2-25
2-26
2-27
2-28
2-29
2-30
2-31
2-32
2-33
2-34
2-35 © Copyright IBM Corp. 2003 Key business processes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
e-business infrastructure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
IBM Application Framework for e-business . . . . . . . . . . . . . . . . . . . . . . 10
J2EE components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
WebSphere Application Server 4.0 in a typical e-business application . 17
Server groups and clones . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Vertical clones . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Horizontal clones . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Types of requests that can be workload managed . . . . . . . . . . . . . . . . 24
WebSphere administrative model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
WebSphere administrative interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . 28
A typical application flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
WebSphere Queuing Network . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Web container queue settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
ORB thread pool size setting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
Resource Analyzer ORB monitoring . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Bounding ORB pool by setting system property . . . . . . . . . . . . . . . . . . 42
Datasource connection pooling settings . . . . . . . . . . . . . . . . . . . . . . . . 43
JDBC session data alternative . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
Explicit HttpSession invalidation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
Servlet using single threaded model . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
Servlet code using synchronization . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
Servlet code avoiding synchronization. . . . . . . . . . . . . . . . . . . . . . . . . . 49
Judicious use of init() method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
Poor String concatenation technique . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
Correct String concatenation technique . . . . . . . . . . . . . . . . . . . . . . . . . 51
Application level tracing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Deactivating System.out and System.err . . . . . . . . . . . . . . . . . . . . . . . . 53
Accessing entity beans from session beans . . . . . . . . . . . . . . . . . . . . . 54
Wrong way to obtain JDBC connections . . . . . . . . . . . . . . . . . . . . . . . . 55
Correct way to obtain JDBC connections . . . . . . . . . . . . . . . . . . . . . . . 56
Wrong way to acquire a datasource . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
Correct way to acquire a datasource . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
Pass by reference side effects of “No Local Copies” . . . . . . . . . . . . . . . 60
Remove stateful session beans when finished . . . . . . . . . . . . . . . . . . . 61
Wrong way to create a new bean instance . . . . . . . . . . . . . . . . . . . . . . 62
Correct way to create a new bean instance . . . . . . . . . . . . . . . . . . . . . . 62
Minimizing queuing downstream, through upstream queuing . . . . . . . . 66 vii 2-36
2-37
2-38
2-39
2-40
2-41
2-42
2-43
2-44
2-45
2-46
2-47
2-48
3-1
3-2
3-3
3-4
3-5
3-6
3-7
3-8
3-9
3-10
4-1
4-2
4-3
4-4
4-5
4-6
4-7
4-8
4-9
4-10
4-11
4-12
4-13
4-14
4-15
4-16
4-17
4-18
5-1
5-2 viii Resource Analyzer summary report with varying number of clients . . . 68
Resource Analyzer Web container monitoring. . . . . . . . . . . . . . . . . . . . 69
EJB queuing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
Short lived EJB calls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
Resource Analyzer EJB methods average response time. . . . . . . . . . . 72
Resource Analyzer datasource monitoring . . . . . . . . . . . . . . . . . . . . . . 73
Resource Analyzer JVM memory monitoring. . . . . . . . . . . . . . . . . . . . . 75
Setting isolation level attributes in the Application Assembly Tool . . . . 82
Performance monitoring infrastructure. . . . . . . . . . . . . . . . . . . . . . . . . . 87
Performance monitoring settings . . . . . . . . . . . . . ....
View
Full Document
- Winter '13
- Regiane Romano
- International Business Machines Corporation, IBM WebSphere Application Server, IBM DB2, IBM WebSphere