30

Jud con presentation_brazil

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: Jud con presentation_brazil
Page 2: Jud con presentation_brazil

The Developer Swiss Knife: Troubleshooting Tools for Java EE Applications

Page 3: Jud con presentation_brazil

Assumptions

•This presentation aims experienced developers with a little (but good) knowledge about how the JVM works•The presentation focus only on the tools, not on the troubleshooting methods•Some of the tools are only for Linux. Windows users, get out! =P•All tools presented in this presentation are Open Source projects and some of them are developed by JBoss

Page 4: Jud con presentation_brazil

The Application stack

Our primary focus

Page 5: Jud con presentation_brazil

The Tools

•JDK CLI Tools (jstack, jmap, jps, etc.)•JDK GUI Tools (JVisualVM, JConsole)•Eclipse Memory Analyzer Tool (MAT)•Thermostat•Garbagecat•Samurai•AS7 JDR (JBoss Disaster Report) tool•Tattletale•Byteman*

Page 6: Jud con presentation_brazil

JDK has its own troubleshooting tools

● jps● jmap● jinfo● jhat● jstack

Page 7: Jud con presentation_brazil

Some of them are Graphical

● JConsole● JVisualVM

Page 8: Jud con presentation_brazil

What should I do when my application has a memory problem?

Page 9: Jud con presentation_brazil

Generating a Heap Dump

● -XX:-HeapDumpOnOutOfMemoryError● jmap● JVisualVM

Page 10: Jud con presentation_brazil

Ok, I have a Heap Dump. Now can I analyze it?

Page 11: Jud con presentation_brazil

Meet Eclipse MAT

Page 12: Jud con presentation_brazil

What should I do if my application have a CPU problem? e.g. High CPU consumption

Page 13: Jud con presentation_brazil

Generating a Thread Dump

● jstack● kill -3● AS7 CLI command:

– /core-service=platform-mbean/type=threading:dump-all-threads(locked-monitors=true,locked-synchronizers=true)

Page 14: Jud con presentation_brazil

Now with a Thread Dump, what should I do with it?

Page 15: Jud con presentation_brazil

Samurai – A Thread Dump viewer

Page 16: Jud con presentation_brazil

High CPU consumption can be high GC activity

Page 17: Jud con presentation_brazil

Enabling GC Logging

● Add to java command:

-XX:+PrintGC -Xloggc:gc.log -XX:+PrintGCDetails -XX:+PrintGCTimeStamps

Page 18: Jud con presentation_brazil

GC Log content

3.122: [GC 132096K->24592K(504320K), 0.0321910 secs]

4.558: [GC 156688K->26752K(504320K), 0.0340520 secs]

6.609: [GC 158848K->50117K(504320K), 0.0628430 secs]

7.077: [GC 80334K->54921K(504320K), 0.0416730 secs]

7.119: [Full GC 54921K->46716K(504320K), 0.2522170 secs]

8.510: [GC 178812K->60924K(504320K), 0.0190690 secs]

9.683: [GC 193020K->69447K(461696K), 0.0308020 secs]

Page 19: Jud con presentation_brazil

Garbagecat

java -jar garbagecat-1.0.0.jar --help

usage: garbagecat [OPTION]... [FILE]

-h,--help help

-o,--options <arg> JVM options used during JVM run

-p,--preprocess preprocessing flag

-s,--startdatetime <arg> JVM start datetime (yyyy-MM-dd HH:mm:ss,SSS)

for converting GC logging timestamps to datetime

-t,--threshold <arg> threshold (0-100) for throughput bottleneck

reporting

Page 20: Jud con presentation_brazil

Garbagecat report========================================

Throughput less than 90% for PARALLEL_SCAVENGE

========================================

18020.492: [GC [PSYoungGen: 161888K->1376K(166016K)] 949359K->789159K(1214592K), 0.0294550 secs]

...

========================================

SUMMARY:

========================================

# GC Events: 46044

GC Event Types: PARALLEL_SCAVENGE, PARALLEL_SERIAL_OLD

Max Heap Space: 1566912K

Max Heap Occupancy: 1562164K

Max Perm Space: 77864K

Max Perm Occupancy: 46645K

Throughput: 99%

Max Pause: 4098 ms

Total Pause: 1703657 ms

First Timestamp: 4616 ms

Last Timestamp: 232465068 ms

========================================

0 UNIDENTIFIED LOG LINE(S):

Page 21: Jud con presentation_brazil

Applications also might have classloading problems

Page 22: Jud con presentation_brazil

Tattletale

Page 23: Jud con presentation_brazil

JBoss AS7 has JDR

Page 24: Jud con presentation_brazil

Wait a minute! I tried to run jvisualvm in OpenJDK and it says “command not found”

Page 25: Jud con presentation_brazil

Thermostat – The next heat

Page 26: Jud con presentation_brazil

Please Remember

● Don't develop applications without make use of testing approaches (unit, integration, functional, ...)

● Although all testing efforts, there is no 100% bug free applications

● For all unpredictable and complex problems, this presentation will help you troubleshoot, if not all, most of the problem

Page 27: Jud con presentation_brazil

The links

● http://icedtea.classpath.org/wiki/Thermostat

● http://eclipse.org/mat/

● http://yusuke.homeip.net/samurai/en/index.html

● https://code.google.com/a/eclipselabs.org/p/garbagecat/

● http://docs.oracle.com/javase/7/docs/index.html

● http://www.jboss.org/tattletale

● http://jboss.org/byteman

Twitter: @rimolivehttp://aprendendo-cloud-computing.blogspot.com

Page 28: Jud con presentation_brazil

Thank you!

Page 29: Jud con presentation_brazil

What about Byteman?

Page 30: Jud con presentation_brazil

Race Condition Tests with BytemanFlávia Rainone

Don't miss it!