Track Name: Application Infrastructure Topic : WebSphere Application Server Top 10 Performance Tuning Recommendations. Presenter Name : Vishal A Charegaonkar WebSphere Architect (Performance and Monitoring)
2
What are we going to talk about Overview of the top best practices that have been derived from customers over the past 6 years. Detailed approach from Operating System on up focusing on the system as a whole Real customer cases where issues have presented themselves Various Tools and tips 3
#10 Understand and Tune Infrastructure Holistically WebSphere Application Server and dependency on rest of infra Think of your infrastructure as a plumbing system. Optimal drain performance only occurs when no pipes are clogged. 4
#10 Understand and Tune Infrastructure Holistically On the WAS system itself you need to be vary aware of What other WAS instances (JVMs) are doing and their CPU / IO profiles memory other WAS instance Network utilization of other applications coexisting on the same hardware On the database system Ensure that proper indexes and tuning is done for the applications request Ensure that the database supports the number of connected clients your WAS runtime will have Understand the CPU load and impacts of other applications (batch, OLTP, etc all competing with your applications) Storage Configuration. 5
#9 Correctly Tune The JVM Garbage Collection JVM and Garbage Collection (GC) Impact of GC on Application Various GC policies Application requirements and GC policies Very short GC trigger pause times Maximum throughput A balance of both GC Tuning approach 1. Select correct GC policy (optthruput, optavepause, gencon) 2. Heap sizing is correct 3. Third step is to look for specific performance issues 6 MIN HEAP JAVA HEAP MAX HEAP
#9 Correctly Tune The JVM Garbage Collector Memory Visualizer (GCMV) Provided as a downloadable plug-in within the IBM Support Assistant Excellent tool for diagnosing GC issues or refining JVM tuning 7 7
#8 Minimize HTTP Session Content High performance data replication for application availability depends on correctly sized session data Keep it under 1 MB (?) in all cases if possible Only should be storing information critical to that users specific interaction with the server Configure Session Replication in WAS to meet your needs Use different configuration options (async vs. synch) to give you the availability your application needs without compromising response time. Select the replication topology that works best for you (DB, M2M, M2M Server) 8
General Tips : PMI and TPV (Monitoring sessions) Using PMI (Performance Monitoring Infrastructure) & TPV (Tivoli Performance Viewer. What is PMI/TPV? PMI Basic Level provides LiveCount. Use PMI Custom Level for SessionSize. 9
#7 Correctly Tune Thread Pools Each task performed by the server runs on a thread obtained from one of the thread pools. A thread pool enables components of the server to reuse threads, eliminating the need to create new threads at run time to service each new request. Three of the most commonly used (and tuned) thread pools within the application server are: Web container: Used when requests come in over HTTP. ORB: Used when remote requests come in over RMI/IIOP for an enterprise bean Default: Used when requests come in for a message driven bean or if a particular transport chain has not been defined to a specific thread pool. 10
#7 Correctly Tune Thread Pools Tivoli Performance Viewer (TPV) Sample of the Web container thread pool PMI data in the viewer. IBM Thread and Monitor Dump Analyzer for Java ActiveCount (red) is the active number of threads at a given time. PoolSize (orange) is the thread pool size. It grows (up Build to into the WebSphere maximum) Admin Console as workload demands increase Available as a downloadable plug-in for the IBM Support Assistant 4.1 (ISA) http://www-01.ibm.com/software/support/isa/download.html Also available on alphaworks (outside of ISA) http://www.alphaworks.ibm.com/tech/jca 11 11
#7 Correctly Tune Thread Pools How to tune thread pool? 1. Monitor ActiveCount 2. Monitor Hardware / Backends utilization 3. Increase (or decrease) thread pool settings 4. Follow 2 and 3 again until you reach optimum value. 12
#6 Tune JDBC Data Sources Correct database connection pool tuning can yield significant gains in performance This pool is highly contended in heavily multithreaded applications so ensuring significant available connections are in the pool leads to superior performance. Monitor PMI metrics via TPV or others tools to watch for threads waiting on connections to the database as well as their wait time. If threads are waiting increase the number of pooled connections in conjunction with your DBA OR decrease the number of active threads in the system In some cases, a one-to-one mapping between DB connections and threads may be ideal 13
#6 Tune JDBC Data Sources Connection Pool information is collected in the PMI Metrics Key metrics recorded include: FreePoolSize - the number of free connections in the pool UseTime - the average time (in ms) that a connection is used WaitingThreadCount the number of threads waiting for a connection to the database WaitTime the average time a thread waits for a connection to the database Questions to answer How busy are my threads in the Connection Pool for this workload? How many threads are waiting for a DB connection? How long it the wait time on an average? 14
#6 Tune JDBC Data Sources Before and After Tuning 15
# 5 Use Application Best Practices for Performance Use the StringBuffer function instead of string concatenations when doing excessive string manipulations to avoid unnecessarily creating objects that eventually must undergo garbage collection. Avoid excessive writing to the Java console to reduce the cost of string manipulations, text formatting, and output. Avoid the costs of object creation and manipulation by using primitive types for variables when necessary. Cache frequently-used objects to reduce the amount of garbage collection needed, and avoid the need to re-create the objects. Group native operations to reduce the number of Java Native Interface (JNI) calls when possible. Use synchronized methods only when necessary to limit the multitasking in the JVM and operating system. Avoid invoking the garbage collector unless necessary. If you must invoke it, do so only during idle time or some noncritical phase. Use the int type instead of the long type whenever possible, because 32-bit operations are executed faster than 64-bit operations. Use the static final key word when creating constants in order to reduce the number of times the variables need to be initialized. Java developers, their process, Avoid unnecessary "casts" and "instanceof" references, because casting in Java is done at run time. the industry and it's technologies Avoid the use of vectors whenever possible when an array will suffice. pay no direct attention to price/performance during Add and delete items from the end of the vector. development, there is no Compile Java files with the -O option. feedback loop. Avoid allocating objects within loops. Use buffer I/O and tune the buffer size. 16 Use connection pools and cached-prepared statements for database access.
# 5 Use Application Best Practices for Performance Some of important points Keep application logging to minimum Build your log message when needed. Example Good } Bad Lazy instantiation Use of Object Pool Example if(loggingenabled==true){ errormsg = This is a bad error + + failingobject.printerror(); System.out.println(errorMsg); errormsg = This is a bad error + + failingobject.printerror(); If(loggingEnabled==true){ } System.out.println(errorMsg); Synchronization.. Can I avoid? http://www.redbooks.ibm.com/abstracts/sg247497.html Redbook : Designing and Coding Applications for Performance and Scalability in WebSphere Application Server. 17
#4 Profile your Application Understand your application architecture. Apply 80/20 Rule to establish 20% of code paths that are most resource-intensive Profile for Single Transaction Method level profiling (filter with package name) Profile and understand your SQL - even generated SQL Employ WAS trace capabilities or DB tools. Tools such as RAD Profiling, ITCAM, Java Health Center, JPROBE 18
Tips : Using Java TM Health Center as profiler *Java is the registered trademark of Oracle Corp 19
#3 Ensure Uniform Configuration Across Servers Uniform configuration of software parameters and even operating systems is a common stumbling block Most times manifests itself as a single machine or process that is burning more CPU, Memory or garbage collecting more frequently Employ a dump configuration script that runs periodically. Store the scripts results off and after each configuration change or application upgrade track differences Good indication that WLM is occurring as desired. 20
#3 Ensure Uniform Configuration Across Servers Another option is to leverage the Visual Configuration Explorer (VCE) tool available within ISA Developer Works article: http://www.ibm.com/developerworks/websphere/techjournal/0710_supauth/0710_supauth.html 21 21
# 2 Perform Proper Load Testing Properly load testing your application is the most critical thing you can do to ensure a rock solid runtime in production. Replicating your production environment isn t always 100% necessary as most times you can get the same bang for your buck with a single representative machine in the environment Calculate expected load across the cluster and divide down to single machine load Drive load and perform the usual tuning loop to resolve the parameter set you need to tweak and tune. Look at load on the database system, network, etc and extrapolate if it will support the full systems load and if not of if there are questions test Performance testing needs to be representative of patterns that your application will actually be executing 22
#2 Perform Proper Load Testing Proper performance testing keeps track of and records key system level metrics as well as throughput metrics for reference later when changes to hardware or application are needed. Always over stress your system. Push the hardware and software to the max and find the breaking points. Only once you have done real world performance testing can you accurately size the complete set of hardware required to execute your application to meet your demand. CHANGE-ONE-VARIABLE-AT-A-TIME & DOCUMENT 23
# 1 Use right Monitoring and PD Tools Categories Tools for live monitoring of production setup Tools for Monitoring during performance test phase Tools for Performance Problem Determination Out-of Box monitoring PMI and TPV Advisors in WebSphere Application Server Use of Request Metrics Additional Tools IBM Support Assistant ITCAM For WebSphere Application Server, ITCAM for Application Diagnostics 24
# 1 Use of Monitoring and PD Tools Tools which are part of IBM Support Assistant Configuration issues Visual Configuration Explorer (VCE) IBM Port Scanning Tool Trace and specialized analysis IBM Trace and Request Analyzer (TRA) IBM Database Connection Pool Analyzer (DCPA / JCP) IBM Web Server Plugin-in Analyzer (WSPA) Log Analyzer (LA) JVM-related issues Java Health Center Memory Analyzer Tool (MAT) Garbage Collection and Memory Visualizer (GCMV) IBM Thread and Monitor Dump Analyzer (TMDA / JCA) 25
Additional Information WebSphere Application Server Performance site http://www-01.ibm.com/software/webservers/appserv/was/performance.html DeveloperWorks Article: Performance Tuning Case Study based on DayTrader http://www.ibm.com/developerworks/websphere/techjournal/0909_blythe/0909_blythe.html Step-by-step approach to tuning the application server based on a sample application WebSphere Application Server Sample Performance Tuning Scripts ftp://ftp.software.ibm.com/software/webservers/appserv/wasv7_tuning_script_templates_v1.0.pdf Can be used to adjust common tuning parameters based on predefined templates or customized to support additional fine tuning Now available within v7.0.0.9 IBM Support Assistant (ISA) http://www-01.ibm.com/software/support/isa/ http://www-01.ibm.com/software/support/isa/download.html Eclipse-based workbench containing support and analysis tools for a variety of IBM products 26 26
Maximize the value of your WebSphere investment The technology you need, when you need it Access to WebSphere Feature Packs Award-winning IBM Support Portal Renewing your IBM Software Subscription and Support is the best way to ensure you get continuous and maximum value Protect your investment Leap ahead of competitors Get up and running faster Download the latest enhancements of entitled WebSphere middleware at no extra charge Enhance your business. Stay current. Renew your software subscription. WebSphere Subscription and Support http://www-01.ibm.com/software/websphere/subscriptionandsupport/ 27
28