Monitoring Java systems

Instrument as early as possible and try JMX today

Earlier in the week I wrote about performance tuning Java systems and I hinted that being able to monitor a system is a really useful first step in proving and diagnosing the cause of performance issues. Of course, there are times where you need a profiler, but that's a different story.

So back to monitoring and I'm still surprised by the number of mission critical systems, particularly in the financial markets sector, where the only way to monitor the system is by tailing a log file. As for management, well, that's typically non-existent.

One of the things that I now do when I'm architecting a new system is to always spend a little time on thinking about the system from an operations/support perspective, reflected by including a "Monitoring and Management View" in my architecture documents. Ultimately, you need to work out what the non-functional requirements are, and a good way to do this is to sit down with the support team to run through the following sorts of questions.

  • Who will be supporting the system?
  • Where are they located?
  • What is their skillset and experience?
  • Will remote support be required?
  • Do you think you'll want to reconfigure the system at runtime?
  • How much control do you want over the log files?
  • Do you have a standard monitoring infrastructure that the system should publish information to? (e.g. Tivoli, BMC, etc)
  • Do you have existing scripts/code/etc for sending (for example) SNMP traps?
  • What granularity of monitoring do you need?
  • What granularity of management do you need?
  • Do you need a single dashboard for the entire system?

Questions like these are important to ask because you really do need to tailor the monitoring and management to the people that will be supporting the application. Of course, like all functionality, you do need to prioritise monitoring and management features because they do have an associated cost. Similarly, you also need to perform some cost-benefit analysis because it's no good building a comprehensive web-based administration system for a tactical solution that only has a 3 month lifepsan, for example.

With Java, a really effective way to monitor and manage applications is using the Java Management Extensions (JMX). As I've said before, JMX is one of those technologies that rarely gets a look in, but once you get into it, you'll become infected. Using JMX is straightforward enough, but you do need to work out what you want to monitor and manage. With this in mind, I would recommend getting those hooks in as early as you can. Finally, even if you *really* don't have the time to instrument your code, you can get a certain level of JVM monitoring for *free*, just by enabling the JMX agent. Try it, you have no excuse not to!

About the author

Simon is an independent consultant specializing in software architecture, and the author of Software Architecture for Developers (a developer-friendly guide to software architecture, technical leadership and the balance with agility). He’s also the creator of the C4 software architecture model and the founder of Structurizr, which is a collection of open source and commercial tooling to help software teams visualise, document and explore their software architecture.

You can find Simon on Twitter at @simonbrown ... see for information about his speaking schedule, videos from past conferences and software architecture training.

Re: Monitoring Java systems

Hi Simon. This comment links in some way with the ones in your previous post. JMX rocks. No doubt. I totally agree with you and I am really infected :) One of the best and most ignored APIs in Java without any doubt. However, JConsole... mmm.. ok, far from perfect I would say. You'll find plenty of errors if you enter the world of firewalls, NAT, authentication, and so on. On the other hand, JRockit offers a great management support, with plenty of useful tools like Mission Control that is just an amazing piece of software for monitoring. For example in my VPS I can't use any Sun tool like JConsole or VisualVM for monitoring. Just migrated to JRockit and tried Mission Control and everything works like a charm :) So, another reason to consider JRockit: monitoring.

Re: Monitoring Java systems

I agree with you; JConsole is a little basic although it is free and you can enhance it by writing plugins on Java 6. Mission Control though ... that looks like a very useful tool.

Add a comment Send a TrackBack