Search |
|||||||||||||||||||||
How much does it cost to monitor an app with jconsole?Posted by emcmanus on July 21, 2006 at 8:39 AM PDT
Recently I've seen several people ask what the cost of enabling
JMX monitoring on an application is. If I run with
Here's the quick answer for people who look at the answers in
the back of the book. Running with
The answer to this question is likely to depend very much on
the nature of the app and what else is going on in the machine
where it is running. My measurements here are on a toy
application which computes digits of the mathematical constant
e
using Here for reference is the method that the app spends most of its time in:
private static void computeE(int digits) {
BigInteger one = BigInteger.TEN.pow(digits);
BigInteger e = BigInteger.ZERO;
BigInteger invfact = one;
BigInteger n = BigInteger.ONE;
while (invfact.compareTo(BigInteger.ZERO) > 0) {
e = e.add(invfact);
invfact = invfact.divide(n);
n = n.add(BigInteger.ONE);
}
System.out.println(e);
}
Note by the way that the last few digits computed by this method are inaccurate due to truncation of the division results. I ran this method with the I created one thread per CPU to make sure that the machine was CPU-bound. Otherwise we might see zero overhead for enabling monitoring because it might be using an otherwise-idle CPU. Startup time is slightly greater when you enable
monitoring because it needs to do some extra work such as
creating an RMI connector. I assumed that the figure of
interest, though, is the cost while the app is running. So I
measured the time between the creation of the
I used two Java platforms for the measurements: Sun's JDK 1.5.0_07
and a Mustang snapshot (1.6.0-rc-b92). The time for the
computation was 37% better on Mustang, presumably because of
improvements to the JIT
compiler and/or heap management. Also the time is better
still if you run with The first measurement was of the application running without any special command-line parameters. So monitoring was not enabled. This is the baseline for the other measurements.
Then I ran the application with
So with this option we could connect jconsole from the local machine. But I didn't connect jconsole for this measurement. The effect on performance was less than 1% in this case, and in fact any observed difference was less than the margin of error. So there was no significant difference in the time to do the computation. In other words, so long as you don't connect jconsole, enabling monitoring should have no effect on your app's performance. I got the same result when I ran with Running with Then I ran the insecure options again but this time connected Tiger's jconsole from another machine. Here are the figures I got:
So here there's a fairly big impact. Some of this is due to jconsole polling the various JVM MBeans so it can graph the changes in various values like heap size and number of threads over time. There is no way to stop jconsole from doing that, even if you're not interested in that information, but what you can do is change the polling interval. If you change the interval from the default 4 seconds to 1000 seconds, say, then you won't see much impact from polling. (The interval also applies to the graphing of your own attributes, though, so if you want that then you'll have to pay for the JVM polling.) Running Tiger's jconsole with
Jconsole isn't polling, but there's still some overhead, presumably due to background activity from RMI and/or to increased memory usage because of the open connection. Mustang's jconsole, besides being generally nicer, has an optimization that means it obtains the various JVM attributes much more efficiently, so the polling impact is less. Even if you can't migrate your apps to Mustang right now, you might want to download the Mustang JDK just so you can run its jconsole! Here are the figures running the app with the insecure options and connecting with Mustang's jconsole from another machine:
So you get better behaviour from jconsole by default here. And
of course you can still use the
Finally, I tried a few configurations with security enabled
( ReminderThese results are not conclusive! They're merely indicative of one set of measurements on one type of app. The impact could be much greater if the addition of the JMX connection pushed the app into a different mode of operation. For example, the additional memory usage could be enough to change the behaviour of the garbage collector significantly and probably negatively. But you would have to be operating fairly close to the edge of such a possible change for that to happen, meaning it could happen even without the JMX connection if for example the app needed to handle a few more objects. »
Related Topics >>
Open JDK Comments
Comments are listed in date ascending order (oldest first)
|
|||||||||||||||||||||
|
|