Problem Determination of your WebSphere …...Allow users to create, enable and disable validation...
Transcript of Problem Determination of your WebSphere …...Allow users to create, enable and disable validation...
© 2010 IBM Corporation
WebSphere
Problem Determination of yourWebSphere Applications with RAD
Anita Rass Wan, RAD Product Manager
© 2010 IBM Corporation2
IBM Labs Come To You
Agenda
Governance of Code• Creating your own rules - customizing rule templates• Advanced Rule creation• Development process integration• Best Practices
Code coverage and Unit test optimization• Overview• Development process integration
Profiling
Problem scenarios: What should I use?– Crashes, hangs– Memory leaks– Execution bottlenecks
Tuning the JVM
Tuning WebSphere Applications
Questions
© 2010 IBM Corporation3
IBM Labs Come To You
Static Analysis in Rational Application Developer 8.0
Java Code Review to find problems of various types:– Design Principles– Globalization– J2EE & J2SE Best Practices– J2EE & J2SE Security– Naming– Performance– Private API
Rich integrated results view provides click to source navigation– Explanations, examples, and quick fixes for problems
Allow users to create, enable and disable validation rules
Allow users to create their own rules based on rule templates
Produce HTML/PDF reports with violations and metrics
Complete Java Code Review (200+ rules)
© 2010 IBM Corporation4
IBM Labs Come To You
Getting Started with Static Analysis
Launched through SoftwareAnalyzer configuration
Can create multiple configurations– Scope – workspace, working set or
selected projects– Select and configure rules – focus
on a particular aspect for analysis
© 2010 IBM Corporation5
IBM Labs Come To You
Analysis Configuration – Rules
Rule sets– Grouping of selected and configured rules
that are to be run against the resources inthe scope of the analysis
Custom rule sets– Shared through export and import
Rule configuration– Select which rules should be used in the
current configuration– Configure severity of the violations– Change parameters of rules
© 2010 IBM Corporation6
IBM Labs Come To You
Adding Custom Rules
Static analysis component comes with several templates that can be used to define customrules through the preferences
© 2010 IBM Corporation7
IBM Labs Come To You
Advanced Rule Creation
Why?– Sometimes the prepackaged or template based rules aren’t specific enough– Domain specific constraints' or company wide governance enforcement rules
How?– Software Analyzer component is extensible– Can create new categories/subcategories for your new rules– API framework makes it easier to implement
• Rules, quickfixes, and even custom reports
What?– Need to have some background in
• Eclipse• Java• Eclipse JDT for Java rules
© 2010 IBM Corporation8
IBM Labs Come To You
Example – Rule to check for unused imports
New category to hold our rule
New rule definition as part of the new category
Extend the abstract class AbstractCodeReviewRule– Implement analyze()
Optionally implement an associated quickfix by extending JavaCodeReviewQuickFix– Implement fixCodeReviewResult()
© 2010 IBM Corporation9
IBM Labs Come To You
Analyzing Results
Double click andview the violation in
the source view.
Generate reportsHTML/PDF
reports.
Export results inXML for otherreporting tools
© 2010 IBM Corporation10
IBM Labs Come To You
Software Analyzer Reports
Create HTML/PDF reports of different metrics– Results, Ignored Results, Severity Summary,
Severity by Category
© 2010 IBM Corporation11
IBM Labs Come To You
Best Practices
Run Analysis early and often– As part of developer best practice to run periodically– Cost to fix defects rises the further they get into the application’s lifecycle– Logical separation of your application in terms of groups for analysis– Java code for business logic– Java code for connection services– Java code for presentation
Smaller groups of analysis to avoid overwhelming number of results– Especially when first beginning to use the code review capability– Can increase the scope of analysis as code quality improves
Create multiple rule sets to apply to different group types– Globalization rules apply more for java code involved in presentation– Different requirements for code complexity enforcement for business logic vs presentation tier
© 2010 IBM Corporation12
IBM Labs Come To You
Integrating Static Analysis Code Reviews – Builds – Step 1
Export your rule set (*.dat) from the Analyzer Configuration
© 2010 IBM Corporation13
IBM Labs Come To You
Integrating Static Analysis Code Reviews – Builds – Step 2
Add a step to your build process to invoke the analysis.
setWORKSPACE="C:\PROGRA~1\IBM\TeamConcertBuild\buildsystem\buildengine\eclipse\buildDir"
set ECLIPSE="C:\PROGRA~1\IBM\SDP_1"
%ECLIPSE%\eclipse.exe-application com.ibm.xtools.analysis.commandline.AnalyzeApplication-rulefile "d:/rules.dat"-data %workspace%-directory %workspace%-exportdirectory %WORKSPACE%\RADcodeReviewXML
© 2010 IBM Corporation14
IBM Labs Come To You
Agenda
Static Analysis of Code• Creating your own rules - customizing rule templates• Development process integration• Best Practices
Code Coverage• Overview• Development process integration
Advanced Code Review– Creating your own rules – write your own with the Software Analyzer API
Profiling
Problem scenarios: What should I use?– Crashes, hangs– Memory leaks– Execution bottlenecks
JVM tuning
Tuning WebSphere Applications
Questions
© 2010 IBM Corporation15
IBM Labs Come To You
Code Coverage Provides detailed information on what code paths have been encountered during program execution Powerful tool to help determine xUnit test coverage, potential dead code Command line and Ant capability for build integration
– JUnit, code coverage data collection and html report generation
© 2010 IBM Corporation16
IBM Labs Come To You
16
Share code coverage information from automated testcase executionImprove test coverage and quality based on code coverage results
RationalApplicationDeveloper
RationalApplicationDeveloper
RationalTeam Concert
DeveloperRational
Team ConcertDeveloper
© 2010 IBM Corporation17
IBM Labs Come To You
Feedback metrics help identify shortfalls in test coverage
Process feedbackThe project lead will see that the code
coverage results are at expected levels andresolves the defect
Work item resolvedDeveloper checks code into a
build and resolves defect whenhe sees the code coverage
results for the build
Problem determinationDeveloper reviews build results andimports the code coverage results
directly into the source code to see whatsource is missed during the test runs
New tests addedNew tests are added to cover the
code that has not been covered byprevious tests. Runs tests locally
to ensure improved coverage
DevelopmentA defect is opened
against the build that hadthe noticable code
coverage level drop
Process feedbackProject lead notices adrop in code coverage
from previous build
RationalRationalApplicationApplicationDeveloperDeveloper
++Rational TeamRational Team
ConcertConcert
© 2010 IBM Corporation18
IBM Labs Come To You
Code Coverage Integration with RTC
Build system integration– Installable RTC Build System extension– Creates code coverage statistics for BVT tests– Data grouped with build results
…Build Machine 1
Build Machine 2
Build Engine
Build Engine
Code CoverageExtension
Code CoverageExtension
© 2010 IBM Corporation19
IBM Labs Come To You
Code Coverage Integration with RTC
Client side– RTC Build details viewer extension – RAD and Web browser
• Show summary of code coverage statistics• Additional Code Coverage tab to show detailed coverage statistics report
– Integrated work item search and creation– Import to local workspace for rich viewing in navigator and source views
Demo
© 2010 IBM Corporation20
IBM Labs Come To You
Agenda
Governance of Code• Creating your own rules - customizing rule templates• Advanced Rule creation• Development process integration• Best Practices
Code coverage and Unit test optimization• Overview• Development process integration
Profiling
Problem scenarios: What should I use?– Crashes, hangs– Memory leaks– Execution bottlenecks
Tuning the JVM
Tuning WebSphere Applications
Questions
© 2010 IBM Corporation21
IBM Labs Come To You
What is Profile on Server?
Profile on Sever is the ability to look at various performance aspects ofabout your Java application
Similar to Run and Debug on Server. Requires an Agent Controller (AC) running on the target machine to
connect to the JVM Users start the profile action from a web resource or a server instance in
Server Views.
© 2010 IBM Corporation22
IBM Labs Come To You
Agent Controller
A daemon process that enables client applications to launch host processes and interactwith agents that coexist within host processes.
An Agent Controller is required to be running on the target machine being profiled Integrated Agent Controller (IAC) is embedded in RAD for local use case. No additional installation, Automatically enabled. Start and stop on demand.
Standalone Rational Agent Controller ( RAC) is required for remote profiling. Requires additional installation on target WAS machine.
© 2010 IBM Corporation
IBM Labs Come To You
Launch profile on server
© 2010 IBM Corporation24
IBM Labs Come To You
New in RAD v8 – Easy profiling setup
• If using an older RAC on a remote machine, RAD will auto detect theolder version and prompt to add environment variables or upgrade yourRAC
© 2010 IBM Corporation25
IBM Labs Come To You
Quick start Wizard
© 2010 IBM Corporation
IBM Labs Come To You
Select Memory Analysis Option
Instrumentation available for profiling Java applications:•Execution Time Analysis•Memory Analysis•Thread Analysis•User written probes
© 2010 IBM Corporation27
IBM Labs Come To You
Profiling Options
Data collection can be expensive– Application under test slows down– Large amount of data for both man and
machine
Filter Sets– Collect data of interest– Focus on your code– Can be exported for sharing
© 2010 IBM Corporation28
IBM Labs Come To You
Profiling Metrics Determine application behavior
– Execution time, number of calls, call tree
– Memory allocation
© 2010 IBM Corporation29
IBM Labs Come To You
Thread metrics Thread Statistics
Threads Visualizer – view timeline of threads with state
© 2010 IBM Corporation30
IBM Labs Come To You
Custom Profiling– Implement your own Java probes to collect runtime information from your application
Java code fragments– Class variables– Runtime fields
• thisObject• className• …
– Target filters
Custom profiling
© 2010 IBM Corporation
IBM Labs Come To You
Memory Analysis
Memory Analysis is a profiling analysis type for Java 1.5+ which displays collected dataabout Objects during application execution
Instance data collection is a new option that can be enabled during Profiling. It provides theability to inspect the composition of Objects, including obtaining the live Object values,variable names and instance size during the profile session.
The data that has been collected can be exported to an XML file.
© 2010 IBM Corporation
IBM Labs Come To You
Enable Instance Data Collection
© 2010 IBM Corporation
IBM Labs Come To You
Can also import/export to XML file for comparison
© 2010 IBM Corporation34
IBM Labs Come To You
Agenda
Governance of Code• Creating your own rules - customizing rule templates• Advanced Rule creation• Development process integration• Best Practices
Code coverage and Unit test optimization• Overview• Development process integration
Profiling
Problem scenarios: What should I use?– Crashes, hangs– Memory leaks– Execution bottlenecks
Tuning the JVM
Tuning WebSphere Applications
Questions
© 2010 IBM Corporation35
IBM Labs Come To You
IBM Support Assistant
Single access point for finding and downloading support tools for IBM products
Also includes many tools for problem determination, including:– JVM Health Center– Thread and Monitor Dump Analyzer
Access from RAD launch-pad
© 2010 IBM Corporation36
IBM Labs Come To You
Diagnostic Data
Data from the JVM -– Javacore – thread information– Heapdumps – heap details– Verbose GC logging – garbage collection data
Data from agents connected to the JVM– Health Center– Rational Agent Controller– More detailed information, higher accuracy: thread, heap details, execution flow– More overhead than Javacore or Heapdumps
Data from the Application Server: PMI
© 2010 IBM Corporation37
IBM Labs Come To You
General Strategy
Try to isolate issues using data that’s easily available or obtainable:– Javacores, heapdump files– Use wsadmin to interactively send events to JVM MBean
If problem not resolved with this level of information– Narrow area of investigation and use filtering combined with more detailed data collection agents
There is often more than one tool that could be used
Measure, measure, measure!
© 2010 IBM Corporation38
IBM Labs Come To You
Crashes
Problem: The untimely death of an application
View WebSphere server logs
Use Thread and Monitor Dump Analyzer–Javacore file from the application–Identifies where the threads last executed
© 2010 IBM Corporation39
IBM Labs Come To You
Problem: App is completely unresponsive
Use Rational Application Developer– Complete hangs - run under debugger and pause after unresponsive point– Hangs/deadlocks
• Thread Analysis for more detailed data• Thread statistics and Threads Visualization contention
Use Thread and Dump Analyzer
Hangs & Deadlocks
© 2010 IBM Corporation40
IBM Labs Come To You
Memory Leaks / Excessive Memory Use
Problem:– Slowdown due to increased garbage collection– Reduced number of concurrent sessions
Use Rational Application Developer– Use Memory Analysis– Identify offending object types– Restart analysis, tracking object allocation sites if understanding where they’re being
allocated is needed
Consider reducing session timeout to reduce longevity of session objects
© 2010 IBM Corporation41
IBM Labs Come To You
Bottlenecks – Overly Aggressive Locking
Problem: slow responsiveness and throughput of web apps
Potential cause: multithreaded code blocks protect more than they need
Use Rational Application Developer– Thread Analysis for more detailed data– Thread statistics and Threads Visualization to view overlapping contention areas over time– Investigate long lock areas
Demo
© 2010 IBM Corporation42
IBM Labs Come To You
Bottlenecks – Inefficient Code Paths
Problem: Slow responsiveness and throughput of web apps
Potential cause: redundant calls or long running code
Use Rational Application Developer– Execution time analysis for detailed metrics– Look for long cumulative times and base times
Demo
© 2010 IBM Corporation43
IBM Labs Come To You
Agenda
Governance of Code• Creating your own rules - customizing rule templates• Advanced Rule creation• Development process integration• Best Practices
Code coverage and Unit test optimization• Overview• Development process integration
Profiling
Problem scenarios: What should I use?– Crashes, hangs– Memory leaks– Execution bottlenecks
Tuning the JVM
Tuning WebSphere Applications
Questions
© 2010 IBM Corporation44
IBM Labs Come To You
JVM Tuning – Garbage Collection Strategy and Heap size
Potential Issues:– Pause times – server unable to process requests due to GC pause times– Factors affected GC frequency and size/number of session objects supported
• Garbage collection policies• Heap size parameters
Use Health Center – live recommendations for GC strategy and heap size– Execute a reasonable portion of your application first
Use Garbage Collection and Memory Visualizer– Enable verbose GC output– Provides more detailed tuning recommendations
Demo
© 2010 IBM Corporation45
IBM Labs Come To You
Agenda
Governance of Code• Creating your own rules - customizing rule templates• Advanced Rule creation• Development process integration• Best Practices
Code coverage and Unit test optimization• Overview• Development process integration
Profiling
Problem scenarios: What should I use?– Crashes, hangs– Memory leaks– Execution bottlenecks
Tuning the JVM
Tuning WebSphere Applications
Questions
© 2010 IBM Corporation46
IBM Labs Come To You
WebSphere Application Server Tuning
Server configuration can affect the performance of your application
Analysis Tools– Enable logging of key PMI data via admin console
• Open tivoli view – showing various tabs that can be monitored• Start logging activity for scenarios you want to optimize for• Use the performance advisor to produce tuning recommendations• Retry the scenario with configuration changes
Demo
© 2010 IBM Corporation47
IBM Labs Come To You
Conclusions Finding problems early in development saves money
Code Coverage from Rational Application Developer running on a server– Verify what get’s touched incrementally– Combine with unit tests or BVT to automate and track
Many tools available to aid in problem determination:– Understanding what the various diagnostic data contains helps guide problem determination strategy for
particular problems• Different tools operate on different input data
– Detailed and accurate data collection incur overhead• Identify focus areas to filter data collection
– WebSphere Application Server contains embedded performance monitoring• Useful Java EE centric performance data• Advisor provides server tuning suggests for you applications
© 2010 IBM Corporation48
IBM Labs Come To You
© IBM Corporation 2011. All Rights Reserved.
IBM, the IBM logo, and ibm.com are trademarks orregistered trademarks of International Business MachinesCorp., registered in many jurisdictions worldwide. Otherproduct and service names might be trademarks of IBM orother companies. A current list of IBM trademarks isavailable on the Web at “Copyright and trademarkinformation” at www.ibm.com/legal/copytrade.shtml.
Copyright and Trademarks
© 2010 IBM Corporation49
IBM Labs Come To You
Export Collected Object Data The data, such as in the example below, can be exported and used for comparison<?xml version="1.0" encoding="UTF-8" ?>
<heap-instance-data version="1">
…<complex-obj tid="418" parent-tid="429" class="Keystore" package="live.instance.test" size="16">
<object tid="423" parent-tid="418" class="Entry:entries" package="" size="24"/>
</complex-obj>
<complex-obj tid="422" parent-tid="423" class="Entry:next" package="" size="24">
<primitive type="String" name="value">Value 1</primitive>
<primitive type="String" name="key">Key 1</primitive>
</complex-obj>
<complex-obj tid="423" parent-tid="418" class="Entry:entries" package="" size="24">
<object tid="422" parent-tid="423" class="Entry:next" package="" size="24"/>
<primitive type="String" name="value">Value 2</primitive>
<primitive type="String" name="key">Key 2</primitive>
</complex-obj>
…</heap-instance-data>