Article: Performance Analysis and Monitoring with Perf4J
In this article Alex Devine explains how Java developers can take advantage of Perf4J, an open source toolset for adding code timing statements and for logging, analyzing and monitoring the results.
In today's world of service-oriented architectures and widely distributed applications, detecting the component responsible for a performance bottleneck can be exceedingly difficult:
Consider what happens on the server in the relatively common scenario of a typical web 2.0-style application:
- An incoming web request is dispatched to the component responsible for generating the response.
- The request may need to be authenticated against an LDAP server.
- The controller component makes queries against a database.
- The controller component also makes calls to a third-party web service.
- The controller component aggregates all of the retrieved data into a set of business objects for display.
- The business objects are rendered and the response is sent to the user's browser.
- AJAX code running in the browser causes additional requests to be sent back to the server
Perf4J is an open source toolset for adding Java server-side code timing statements and for logging, analyzing and monitoring the results. As Alex notes:
For those developers who are familiar with logging frameworks such as log4j or java.util.logging, an analogy helps to describe Perf4J:
Perf4J is to System.currentTimeMillis() as log4j is to System.out.println()
Read the full article: Performance Analysis and Monitoring with Perf4J
This is a great tool to keep track of the performance of our service layer.
My boss definitely like the statistics and how heavy the app is being used :-)
One bad thing is that the Google Chart API gets nuked when the request URI is too long!
I would like the tool to progress in the direction of analyzing the database calls, as most of the performance problems are seen in the database areas.
Nagios support of JMX?
I am curious though on the comment regarding Nagios support of JMX. My investigation shows that this is particularly difficult, unstable and 'hacky' See www.agilejava.com/blog/?p=149 (not written by me btw). Would it be possible to elaborate on the approach used to tie perf4j jmx logs to nagios that has been adopted by Homeaway?
Re: Nagios support of JMX?
The basic Nagios/Cacti usage that we have at HomeAway relies on MX4J's HTTP JMX Adaptor. The server exposes the Perf4J data as described in this article using MX4J.
We then use simple command-line bash scripts to ping the XML MX4J interface from Nagios and Cacti. From there its simple to integrate into both of these products. Thanks to Perf4J, we have performance related alerts and historical charts (above and beyond the ones provided by Per4J) in these other applications.
Hope this helps.
Thanks for such a nice tool.
Re: Nagios support of JMX?
Alex is right; MX4J exposes pretty much all the data we need in an easily consumable format. By adding "&template=identity" to the end of any MX4J url everything is output into XML. We then use a number of simple Perl scripts that consume that XML and run checks against our thresholds specified in Nagios. It's simple, but it works. We do the same thing for Cacti.
I've taken a look at some of the Nagios plugins you've linked to before and basically came to the same conclusion as you, as far as their usefulness.
If you have any other questions let me know.
York Xyander, Bodo Junglas Jul 31, 2015