sábado, 15 de enero de 2011

Monitorize your own applications with hardly any effort: JavaMelody

A developer may think that its job scope is bound to the functional part of the application. Valid and validated, the application runs and works fine. It meets the specifications and never hangs, dies or misfunctions, it is documented and tested. For god's sake, it is the best application I have ever seen.

But this developer cannot answer some very easy questions: Is it running right now? How can I know it is running? Can I automatize this knowledge in any way?

If your application is a CRUD database manager for documents, you can enter in the application, notice it is up, login yourself and use the wet finger method for more health and performance measures. However, if your application controls thermonuclear weapons, please make us a favor and resign.

I was asked to develop a plugin for every company application, in order to get current status, some statistics and maybe perform some executions to self-testing methods. After several weeks and thousands of euros invested on this project, I managed to create a /checkUp servlet that performed a database test and, if /checkUp responded "ok", then we assumed that the application was up.

Fortunately,  JavaMelody did this for us, much better, much easier, much appealing... I couldn't have done it better, for sure.

Follow the installation, just include 2 jars and 10 lines in your web.xml file, and you will have lots of statistics, a /monitoring servlet giving all pretty-printed data and some performance measures.

From its web:

"The goal of JavaMelody is to monitor Java or Java EE applications servers in QA and production environments. It is not a tool to simulate requests from users, it is a tool to measure and calculate statistics on real operation of an application depending on the usage of the application by users.

JavaMelody is opensource (LGPL) and production ready: in production in an application of 25 person years. JavaMelody is easy to integrate in most applications and is lightweight (no profiling and no database).

JavaMelody is mainly based on statistics of requests and on evolution charts.

It allows to improve applications in QA and production and help to:
give facts about the average response times and number of executions
make decisions when trends are bad, before problems become too serious
optimize based on the more limiting response times
find the root causes of response times
verify the real improvement after optimizations

It includes summary charts showing the evolution over time of the following indicators:
Number of executions, mean execution times and percentage of errors of http requests, sql requests, jsp pages or methods of business façades (if EJB3, Spring or Guice)
Java memory
Java CPU
Number of user sessions
Number of jdbc connections

These charts can be viewed on the current day, week, month, year or custom period.
"

Certainly, installing it took me no more than 10 minutes, using Maven dependencies, on an already existent application, and result was impressive, something like this (took from JavaMelody):



Something similar can be got using JMX, but it takes longer, and it is less human readable.

Try it in any of your applications, you will repeat!

Albert Navarro :)

No hay comentarios:

Publicar un comentario

Nota: solo los miembros de este blog pueden publicar comentarios.