2. Agenda ●●●●
• Introduction
• JVM & Memory Structure in JVM
• JMX and MBean
• Jmxtrans as a JVM query tool
• Demo graphite as a JVM historical data manager tool
• Tips and tricks
• Q&A
www.exoplatform.com
2
Copyright 2011 eXo Platform
3. Introduction
●●●●
Purpose of this presentation:
Purposes of monitoring a JVM
Introduce about a way to monitor a JVM
Introduce about how to build an eXo product JVM monitoring
system
This presentation serves to:
● Leaders to understand about performance test reports and to give
advices & suggestions with performance test reports base on the JVM
detail information
● Who is new in using JVM monitoring tools
● Testers who have to work directly and often with JVM
monitoring tools
www.exoplatform.com
3
Copyright 2011 eXo Platform
5. Value of code (Value of a product) ●●●●
Value of a software product
• Meet the business requirement
• Users satisfaction
• Save time and money, give more business value
• Rich features
• Stable, high performance
• Easy to backup/maintain/improve
• …
www.exoplatform.com
5
Copyright 2011 eXo Platform
6. We want to make our code more value ●●●●
• The code generates value when it is used/run/inherit not when we
write it
• We need to know how our code performed when it run
• We cannot do this unless we measure it
www.exoplatform.com
6
Copyright 2011 eXo Platform
7. Why measure ●●●●
• map ≠ territory
• map of Ha noi ≠ city of Ha noi
• the way we talk ≠ the way it is
• the way we think of ≠ the way itself
• perception ≠ reality
www.exoplatform.com
7
Copyright 2011 eXo Platform
8. Why measure – mental model, it's not the code ●●●●
• We have mental model of the code
• mental model, it's not the code
• Sometime, it's wrong
• Sometime, it’s a big mistake
www.exoplatform.com
8
Copyright 2011 eXo Platform
9. Why measure – cont. ●●●●
• We cant know until we measure it
www.exoplatform.com
9
Copyright 2011 eXo Platform
10. Why measure – cont. ●●●●
• This affect how we make decisions
• A better mental model make us better at deciding what to do
• A better mental model make us better at generating value
• Measuring make our decisions better
www.exoplatform.com
10
Copyright 2011 eXo Platform
15. JMX and MBean
www.exoplatform.com
Copyright 2011 eXo Platform
16. What is the JMX ●●●●
• Java Management Extension
• It consists of:
• An architecture
• Design patterns
• Java APIs
• Services for application and network management
www.exoplatform.com
16
Copyright 2011 eXo Platform
17. What is the JMX (cont.) ●●●●
• Enables Java applications to be managed without heavy
investment
– Little impact on Java application design
• Provides scaleable management architecture
– Component architecture, pick and choose components
• Integrates existing management solutions
– Can be managed via multiple protocols, e.g. SNMP, WBEM, HTTP
– Information model independent
• Leverages existing standard Java
www.exoplatform.com
17
Copyright 2011 eXo Platform
19. The JMX architecture (cont.) ●●●●
• The JMX architecture defines three levels:
– Instrumentation Level
• How to instrument managed resources
– Server Level
• How managed resources are managed via the management server
– Distributed Services Level
• How distributed clients and management applications access and
interact with servers and the managed resources in the servers
www.exoplatform.com
19
Copyright 2011 eXo Platform
20. The JMX architecture (cont.) ●●●●
• Basic goal
– In a running Java application, we would like to be able to:
• Manage existing Java objects:
– get an attribute value
– change an attribute value
– invoke an operation
• Add new Java objects:
– using existing Java classes
– using new classes from an arbitrary location
• And do all this from a remote location
www.exoplatform.com
20
Copyright 2011 eXo Platform
21. MBean ●●●●
• MBean: Managed bean. Java class implementing a management
interface and representing a resource to be managed or
monitored
• MBean
– Defines how resources are instrumented using MBean
– MBean instrumentation allows the resource to be manageable
through JMX-compliant agents
• Notification Model
– MBean and other JMX components
may emit notifications
• MBean Metadata Classes
– Describes the MBean's management
interface for management agents
and management
www.exoplatform.com
21
Copyright 2011 eXo Platform
22. MBean (cont.) ●●●●
• An MBean exposes the management interface of the
managed resource/object
– The management interface is the set of information and controls that
a management application uses to operate on the resource
www.exoplatform.com
22
Copyright 2011 eXo Platform
23. MBean (cont.) ●●●●
• An MBean exposes the management interface as:
– Attributes which may be accessed
– Operations which may be invoked
– Notifications which may be emitted (optional)
– Constructors for the MBean's Java class
• An MBean follows design patterns
– The way an attribute or operation to be exposed has to be declared
• An MBean must be registered in the MBean server to be
visible remotely
• An MBean does not know about its MBean
www.exoplatform.com
23
Copyright 2011 eXo Platform
24. MBean (cont.) ●●●●
• The MBean server is a registry of objects which are exposed
to management operations in a server
– Only registered MBean can be managed from outside the server's
JVM
• The MBean server only exposes an MBean's management
interface (not the MBean's direct reference)
• Also provides standardized interface for accessing MBean
within the same JVM
www.exoplatform.com
24
Copyright 2011 eXo Platform
25. Tools that allow to connect to JVM remotely via JMX
●●●●
• Jconsole
• visualvm
• Memory Analyzer Tool
• …
www.exoplatform.com
25
Copyright 2011 eXo Platform
26. Tools that allow to deal with MBean through web interface
●●●●
• JBoss jmx console
– Enable user name and password here: server/default/conf/props/jmx-
console-users.properties
• javamelody
• …
www.exoplatform.com
26
Copyright 2011 eXo Platform
28. Jmxtrans as a JVM query tool
www.exoplatform.com
Copyright 2011 eXo Platform
29. Jmxtrans introduction
●●●●
• jmxtrans is a tool which allows you to connect to any
number of Java Virtual Machines (JVM's) and query them for
their attributes without writing a single line of Java code
• The attributes are exported from the JVM via Java
Management Extensions (JMX)
• eXo Platform and others implement MBean interface
• The query language: JSON format.
• OutputWriters:
– write output automatically base on class name
– can output to: graphite, gangila, keyout, RRD...
www.exoplatform.com
29
Copyright 2011 eXo Platform
34. Jmxtrans query – single query
●●●●
• TARGET_JMX_PORT = eXo product JMX port
• TARGET_JMX_HOST = eXo product host address
• TARGET_GRAPHITE_HOST = graphite server address
• TARGET_GRAPHITE_PORT = graphite server port
• outputWriters class:
com.googlecode.jmxtrans.model.output.GraphiteWriter
www.exoplatform.com
34
Copyright 2011 eXo Platform
35. Jmxtrans query – single query – MBean query part ●●●●
www.exoplatform.com
35
Copyright 2011 eXo Platform
36. Jmxtrans query – single query – Output part
●●●●
www.exoplatform.com
36
Copyright 2011 eXo Platform
37. Jmxtrans query – single query – list of query
●●●●
www.exoplatform.com
37
Copyright 2011 eXo Platform
38. Jmxtrans query – wildcard syntax
●●●●
• Jmxtrans support wildcard syntax
• typeNames should be defined wildcard applied
– Purpose is: filtering and classifying
www.exoplatform.com
38
Copyright 2011 eXo Platform
39. Demo graphite as a JVM historical data
manager tool
www.exoplatform.com
Copyright 2011 eXo Platform
40. Install & using graphite
Install graphite
Build graphite dashboards
Data calculation while building graphs
get single image by URL
Export graph data to csv data format
www.exoplatform.com
Copyright 2011 eXo Platform
46. Tips & tricks
• Perform jmxtrans.sh start many time until the messgae
that there is a jmxtrans process exist
• jmxtrans must start after the application start
• use curl, wget… to collect specific data/graph from
graphite automatically
• use the graphs’ csv datasheet to compare data between
graphs’ content
• A graph with multiple data lines can hide some
information from some line. Try to expand into multiple
graphs
• try to export all the data in a needed term to use later
• Default graphite data history is 24hours, it should be
changed to longer to avoid missing of needed data
www.exoplatform.com
Copyright 2011 eXo Platform
* "our application is slow, this page takes 5s, fix it!" find the bottleneck! - template rendering? - SQL query? - Session storage? find the bottleneck! - template rendering? - SQL query? - Session storage?
* "our application is slow, this page takes 5s, fix it!" find the bottleneck! - template rendering? - SQL query? - Session storage? find the bottleneck! - template rendering? - SQL query? - Session storage?
A runtime instance of the Java virtual machine has a clear mission in life: to run one Java application. When a Java application starts, a runtime instance is born. When the application completes, the instance dies. If you start three Java applications at the same time, on the same computer, using the same concrete implementation, you'll get three Java virtual machine instances. Each Java application runs inside its own Java virtual machine.
* "our application is slow, this page takes 5s, fix it!" find the bottleneck! - template rendering? - SQL query? - Session storage? find the bottleneck! - template rendering? - SQL query? - Session storage?
• Client: Application controlling servers by submitting requests, activating new services, etc ... • Server: Application making local resources available remotely and providing one or more services • MBean server: Registry for MBean in the server • MBean: Managed bean. Java class implementing a management interface and representing a resource to be managed or monitored