+ All Categories
Home > Technology > Monitoring and Tuning GlassFish

Monitoring and Tuning GlassFish

Date post: 11-Nov-2014
Category:
Upload: c2b2-consulting
View: 6,804 times
Download: 2 times
Share this document with a friend
Description:
'In the Wild'presentation by Steve Millidge
Popular Tags:
45
GlassFish Monitoring and Troubleshooting In the Wild Steve Millidge C2B2 Consulting Limited
Transcript
Page 1: Monitoring and Tuning GlassFish

GlassFishMonitoring and Troubleshooting

In the Wild

Steve Millidge

C2B2 Consulting Limited

Page 2: Monitoring and Tuning GlassFish

CAVEATIf this works it’ll be a miracle!

Page 3: Monitoring and Tuning GlassFish

Agenda

• Setting the Scene– A Real World? Scenario

• Command Line Tools

• Graphical Tools

Page 4: Monitoring and Tuning GlassFish

Setting the Scene

Troubleshooting in the Wild!

(An Apology)

Page 5: Monitoring and Tuning GlassFish

C2B2 Consulting

• Fast– Performance and Scalability

• Reliable– High Availability and Recoverability

• Manageable– Monitoring and Supporting

• Secure– Security

Page 6: Monitoring and Tuning GlassFish

First Day At Work

Page 7: Monitoring and Tuning GlassFish

It’s All Gone to *#*@!

Page 8: Monitoring and Tuning GlassFish
Page 9: Monitoring and Tuning GlassFish
Page 10: Monitoring and Tuning GlassFish
Page 11: Monitoring and Tuning GlassFish

Meet the Project Manager

Page 12: Monitoring and Tuning GlassFish
Page 13: Monitoring and Tuning GlassFish
Page 14: Monitoring and Tuning GlassFish
Page 15: Monitoring and Tuning GlassFish
Page 16: Monitoring and Tuning GlassFish
Page 17: Monitoring and Tuning GlassFish
Page 18: Monitoring and Tuning GlassFish

Where do You Start?

Page 19: Monitoring and Tuning GlassFish

JVM Versions

• JDK 1.4– Black Box

• JDK 1.5– You can watch from outside

• JDK 1.6– You can sneak in by the back door

Page 20: Monitoring and Tuning GlassFish

JVM Command Line Tools

• jps– Identified Running Machines on the Host

• jstat– Provides Statistics on Running VMs

• jmap– Provides Memory Information

• jstack– Provides Stack Trace Information

Page 21: Monitoring and Tuning GlassFish

jps

• Lists the Running VMs on a Host

• -l shows you the class name

• -m The Command Line Parameters

• -v full Java Options

Page 22: Monitoring and Tuning GlassFish

GlassFish Command Line Tools

• asadmin– Command line access to GlassFish

• Orientation– list-domains– list-clusters– get-health– generate-diagnostic-report – generate-jvm-report

Page 23: Monitoring and Tuning GlassFish

GlassFish Monitoring

• Check Monitoring– get server.monitoring-service.module-

monitoring-levels.*

• Switch Monitoring On– set server.monitoring-service.module-

monitoring-levels.jvm=LOW

• Monitor– Monitor –type jvm

Page 24: Monitoring and Tuning GlassFish

jstack

• Dumps a stack trace

• Adds monitors and Synchronizers

• C stack as well on Linux

Page 25: Monitoring and Tuning GlassFish

jstat

• Provides Memory Stats– Perm Gen, New Gen, Old Gen

• Provide Class Loading Stats

• Provide Compilation Stats

Page 26: Monitoring and Tuning GlassFish

jinfo

• Provides Information on the Running VM– Command Line– System Properties– VM flags

• Changes the flags in the VM

• Limited use on Windows

Page 27: Monitoring and Tuning GlassFish

jmap

• Gives you visibility into the memory

• See the Class Histogram

• Dump the Memory to a File

Page 28: Monitoring and Tuning GlassFish

jhat

• Heap Analyzer

• Works from a Dump File

• Browse the Heap via a Browser

Page 29: Monitoring and Tuning GlassFish

Graphical Tools

Page 30: Monitoring and Tuning GlassFish

GlassFish AdminConsole

Page 31: Monitoring and Tuning GlassFish

Admin Console

Page 32: Monitoring and Tuning GlassFish

Visual VM

• New in 1.6u7

• Replaces JConsole

• Number of plugins

• Enables Heap Dumps

• Thread Dumps

• Simple Profiling– Pretty Dodgy (Often Crashes VM)

Page 33: Monitoring and Tuning GlassFish

Third Party Tool

Page 34: Monitoring and Tuning GlassFish

Memory Analyzer Tool

• Open Source

• Developed by SAP Support

• Analyses Heap Dumps– Finds Culprits Easily– Indexes the dump for fast navigation

Page 35: Monitoring and Tuning GlassFish

Analysis

• We are Leaking Memory in a static– Class name and variable

• We have a rogue thread spinning the cpu– Full stack trace

Page 36: Monitoring and Tuning GlassFish
Page 37: Monitoring and Tuning GlassFish

Exotica

When things get really tough!

Page 38: Monitoring and Tuning GlassFish

Exotica

• Oracle JRockit

• Attach API

• Instrumentation API

• BTrace

Page 39: Monitoring and Tuning GlassFish

Oracle JRockit

• Supports 1.4, 1.5, 1.6• Ships with Many Advanced Tools• Mission Control• Leak Analyzer

– Looks for Increasing Dominators in Real Time

• Latency Analyzer– Records cause of Thread Latency in Real Time

• Instrumentation in the VM itself

Page 40: Monitoring and Tuning GlassFish

Attach API

• Enables tools to Dynamically Attach to a JVM

// attach to target VM VirtualMachine vm = VirtualMachine.attach("2177");

// construct path to management String agent = "management-agent.jar"; // load agent into target VM vm.loadAgent(agent)

vm.loadAgent(agent);// detach vm.detach();

Page 41: Monitoring and Tuning GlassFish

Agents

• Agent is a JAR file

• Define Premain Class in the Manifest– Has method premain(String args)

• Define Agent Class in the Manifest– Has Method agentmain(String args)

Page 42: Monitoring and Tuning GlassFish

Instrumentation

• JDK 6 support in place Class Replacement

• Agents implementClassFileTransformer

• Register themselves as a Transformer– Instrumentation.addTransformer

• Call restransform– Instrumentation.retransform

Page 43: Monitoring and Tuning GlassFish

BTrace

• Uses Attach API and Instrumentation

• Attaches an Agent into the VM

• Injects “scripts” into a running JVM

• Script transform class files and inject code

• http://btrace.dev.java.net

Page 44: Monitoring and Tuning GlassFish

Example Script

// import all BTrace annotations import com.sun.btrace.annotations.*;

// import statics from BTraceUtils class import static com.sun.btrace.BTraceUtils.*; // @BTrace annotation tells that this is a BTrace program @BTrace public class HelloWorld {

@OnMethod( clazz="java.lang.Thread", method="start" ) public static void func() { println("about to start a thread!"); } }

Page 45: Monitoring and Tuning GlassFish

Thank you

Questions?


Recommended