Usemon; Building The Big Brother Of The Java Virtual Machinve

27
Building the "Big Brother" for the Java Virtual Machine Paul René Jørgensen & Steinar Cook

Transcript of Usemon; Building The Big Brother Of The Java Virtual Machinve

Page 1: Usemon; Building The Big Brother Of The Java Virtual Machinve

Building the "Big Brother"for the Java Virtual Machine

Paul René Jørgensen & Steinar Cook

Page 2: Usemon; Building The Big Brother Of The Java Virtual Machinve

Paul René Jørgensen

Paul René started his coding career on the C64, but was really hooked when participating in the demo scene on the Amiga writing graphical presentations in assembly code.

He has worked as a senior consultant at Telenor in Norway for the past 8 year and been part of establishing the Metro middleware.

He loves to code, and do whatever it takes to get the opportunity to write code, whether it is at his desk, on the bus or in bed.

Usemon has been developed on and off for the past 3 years, but got extra momentum when Steinar joined the project in Q3, 2007.

Page 3: Usemon; Building The Big Brother Of The Java Virtual Machinve

Steinar Overbeck CookSteinar wrote his first program back in 1979 in APL and have been trying to convince his family that programming is work and not fun ever since.

Special interest in software engineering methods, design patterns and SQL databases.

After establishing the DBMS vendor Informix in Norway in the late 90's, which was later sold to IBM, he founded his second company focusing on CRM software.

He is currently involved with his 3rd startup, www.SendRegning.no, focusing on a new SaaS solution for the Scandinavian SMB market

Page 4: Usemon; Building The Big Brother Of The Java Virtual Machinve

Challenges

What goes on in the JVM?Who invokes who?Runtime dependencies (late binding) Who uses the CPU?Irregular use of exceptionsAre the servers balanced in your clustersMain call paths through the entire systemInvocation count and response timesOnly interested in our selected classes and methods

Page 5: Usemon; Building The Big Brother Of The Java Virtual Machinve

Possible Solutions

Many toolsCostlyProprietary

No extension pointsLimited to the built in reports

ComplicatedIntrusive?

Some may require code modifications

Page 6: Usemon; Building The Big Brother Of The Java Virtual Machinve

Possible Solutions (cont.)I'm a programmer and I want to do this myself!

Page 7: Usemon; Building The Big Brother Of The Java Virtual Machinve

Overall Architecture

Page 8: Usemon; Building The Big Brother Of The Java Virtual Machinve

The agent

Bootstrapping the JVMJDK >= 5.0

Hook into the Java Agent InterfaceJDK <= 1.4

Modify system supplied java.lang.ClassLoaderModify the JVM startup

Modification of byte code during class loadingBootstrapping the internal registry and the publisherMeasure and assemble observationsMulti casting observations to the collector

Page 9: Usemon; Building The Big Brother Of The Java Virtual Machinve

Boostrapping JVM >= 5.0

Starting the JVM with modified class loader java -javaagent:usemon-agent.jar

Page 10: Usemon; Building The Big Brother Of The Java Virtual Machinve

Java Agent Interface for JVM <= 1.4

Page 11: Usemon; Building The Big Brother Of The Java Virtual Machinve

Emulating Java Agent Interface

Page 12: Usemon; Building The Big Brother Of The Java Virtual Machinve

JVM <= 1.4 - modifying the class loader

Page 13: Usemon; Building The Big Brother Of The Java Virtual Machinve

Boostrapping JVM <= 1.4

Starting the JVM with modified class loader

java -Xbootclasspath/p:usemon-bootstrap.jar -cp usemon-agent.jar

Run through the java.lang.ClassLoader code and intercept all calls to defineClass0Insert code that let the Usemon RootInstrumentor class modify the byte code before the original defineClass0 is invoked

Page 14: Usemon; Building The Big Brother Of The Java Virtual Machinve

Byte code modification during class loading

Identify interesting classesEnterprise Java Beans

SessionBeansEntityBeans

Message Driven BeansServletsQueueSendersTopicPublishersSqlStatementsSqlConnectionsCustom classes based on user defined patterns

Page 15: Usemon; Building The Big Brother Of The Java Virtual Machinve

Measure and assemble observations

Page 16: Usemon; Building The Big Brother Of The Java Virtual Machinve

Internal registry and the publisherAggregates observations for an interval of 60 seconds:Yields if the JVM is approaching critical state

JVM Garbage Collector removes "Soft references""Soft references" versus "Weak references"

Page 17: Usemon; Building The Big Brother Of The Java Virtual Machinve

Multi casting observations

Goals:Must not interfere with business codeFault toleranceLoose couplings

Assumption:Loosing some observations is acceptable

Conclusion; We needed a message queue!UDP multicast - simplest form of asynchronous messagingProven in battle by Telenor:

Metro logging framework transports several GB per day

Page 18: Usemon; Building The Big Brother Of The Java Virtual Machinve

The collector

Stand alone Java processReceive multi casted observations

Hop countFormat: Java or JSON

Cache observations to increase database insert performanceReorganize and storeDrop observations if heap space falls below threshold

Receive rate higher than storage rateMonitoring and management through JMX

Page 19: Usemon; Building The Big Brother Of The Java Virtual Machinve

The repository of collected data

SQL "star schema" with 3 facts:Method invocationsMethod dependenciesHeap usage

Available dimensions:Location (platform, cluster, server)PackageClassMethod (with signature)PrincipalDate and time

Page 20: Usemon; Building The Big Brother Of The Java Virtual Machinve

Method measurement fact

Page 21: Usemon; Building The Big Brother Of The Java Virtual Machinve

Method dependency fact

Page 22: Usemon; Building The Big Brother Of The Java Virtual Machinve

OLAP / BI

Several OLAP/BI tools availableMostly commercial and expensiveA few OSS tools based upon mondrian

Requires detailed knowledge of the OLAP cube model and MDX query language

Cube model based upon Usemon dimensional modelSimplifies the writing of queriesSlice & dice is much simpler with MDX than SQL

Jasper Server & Jasper Analysis

Page 23: Usemon; Building The Big Brother Of The Java Virtual Machinve

Invocations split over servers for 24h

Page 24: Usemon; Building The Big Brother Of The Java Virtual Machinve

Exceptional exits

Page 25: Usemon; Building The Big Brother Of The Java Virtual Machinve

Current usage in Metro

Usemon is now being used in an ongoing project to discover potential improvements in over 80 enterprise applications on Metro.

We try to find the worst pieces of codeBad response time and a lot of usageBig percentage exception exits

We'll suggest changes and improvements with great accuracy based on the data that Usemon provide.

Page 26: Usemon; Building The Big Brother Of The Java Virtual Machinve

U s e m o n | L i v e

A proof of concept real time UIBased on the Processing data visualization framework

http://processing.orgMade for big screen presentationAnimates class dependencies as graphs

Green arrows is invocationsSpring layout

Page 27: Usemon; Building The Big Brother Of The Java Virtual Machinve

Where can I find it?

Project site is hosted on Google Code under MPL license

http://usemon.org

Presentation slides

http://www.slideshare.net/paulrene