Thursday, July 24, 2008

Approaches to Java application diagnostics

By Madhav Sathe

Even well tested applications may have problems once they go live. More often application problems lead to loss of business. It is really an uphill task to diagnose application problems in real time. Most Java/J2EE diagnostic tools available in the market fail to meet requirements to troubleshoot problems real time.

Some of the common reasons are:

  • Performance overhead is high
  • They enforce application downtime,
  • Require changes to application binaries
  • Complexities in install and deployment

One of common problems in these tracing tools are that they work in Silos and – cannot trace transactions across tiers i.e. from application server to database.

Most commercial applications use a database as the persistence store and the database can often be source of the problem. Unless you address all of these issues you can’t have a product that can be used in production environment.

Usually one of the following techniques are used to debug or profile the JVM and application.

  • Byte code instrumentation (BCI)
  • Aspect oriented programming (AOP)
  • JMX
  • JMVTI

These tools have several drawbacks. BCI and AOP can provide you granularity but are very complex to write but need server restart or redeployment of application. JMX can provide profiling but is not useful in diagnosis. It does not give code level details. JVMTI has overhead of around 10% and that too needs JVM restart. Also these tools are silo oriented, they don’t provide cross tier visibility. Installation and deployment of these tools is complex. All these limitations make them ‘developer tools’.

Fortunately Oracle AD4J (application diagnostics for Java) addresses all of the above-mentioned issues making it perfect for diagnosing production issues of Java application. The most prominent features of AD4J are that it has overhead of less than 1% and it is hot deployable. By hot deployable, I mean it does not require any application changes or server restart. AD4J achieves this by installing an agent (which is a WAR) file that directly readsmetrics/data from JVM s using native calls making it really lightweight.

The other feature that separates AD4J from other tools is its ability to follow transactions from application to database and vice a versa. There are several other features that make AD4J only and the most effective solution for monitoring j2ee applications in production environment.

  • Real time visibility of code and application state
  • Differential memory analysis and finding memory leaks
  • Interactive transaction trace
  • Request performance breakdown by tier, JSP, EJB, JDBC and SQL
  • Trace in-flight transactions
  • System monitoring and reporting

These features make it possible for users to find variety of problems in J2EE applications. Most typical scenarios where people use AD4J are

  • Page hang
  • Slow performance
  • Memory leaks
  • Find out slowest requests and their root cause

You can download AD4J from here. I will write a series of articles explaining the features in details and how to install it.

No comments: