Java VM Monitoring for glassfish applications

29 12 2011

It is good practice to monitor server resources of your webapp. You can really know Your app better with monitoring tools. Not only webapps can be monitored of course.

Recently I encountered some problems with glassfish webapp. I thought that it could be lack of server resources. Although problem was different – I’ve learnt to use some monitoring tools – very useful skill!

There are two free tools You should consider: JConsole, which is included in JDK, and VisualVM which appears to be better for glassfish apps thanks to the dedicated plugin. Tools monitors Memory and CPU usage, active threads and loaded classes for JVM and You can access your webapp remotely with them (provided that traffic is not blocked). Both are user-friendly. Here are some screenshots from GUI:

JConsole GUI

JConsole GUI

VisualVM GUI

VisualVM GUI

JConsole is provided with JDK, so using it does not require installation. It is then good entry point – You can just fire it on localhost and check memory, CPU usage, active threads and classes. Good solution for standalone apps, and starting point for advanced monitoring of webapps. If You’ll find such need You should install VisualVM.

VisualVM can do everything what JConsole can, plus some more: it has dedicated plugin to monitor glassfish web applications (along with a bunch of other plugins). It can show:

  • stats for each (glassfish) application
  • amount of active sessions to Your app
  • max sessions count reached since monitoring started
  • list each servlet in your app and measure the time spent by server on processing it, error count, and hit count.
  • profiler (according to my observations this module influences efficiency of Your webapp, so be careful using it while app is being loaded with big traffic)

It also allows to create snapshots of current monitoring graphs and statistics (it is not just screenshot, but fully usable graphs).

JRockit is another useful suite – full version is paid but, as Oracle representant said, totally helpful and worth trying. Equipped with VisualVM I did not find a need to try anything more. Reading JRockit specifications it seems that tool can be your last help when everything else fails.

Tools mentioned are very useful to find bottleneck of Your app, errors source etc. They do not require a lot of resources to run so You can just fire them and watch graphs. Very useful. Installing them is very easy. Some problems may appear while connecting with app remotely. I’ll describe solutions in the following post.

Did I help you?
I manage this blog and share my knowledge for free sacrificing my time. If you appreciate it and find this information helpful, please consider making a donation in order to keep this page alive and improve quality

Donate Button with Credit Cards

Thank You!


%d bloggers like this: