Does Java Visual VM impacts the performance of the monitored JVM?

3.5k Views Asked by At

I'm considering to profile a production environment with Java Visual VM. I want to montitor:

  • CPU usage
  • GC activity
  • Used Heap
  • Status of threads

Does this monitoring have any significant impact to the performance of the JVM?

3

There are 3 best solutions below

0
On BEST ANSWER

In my experience there is no noticable slowdown unless you are using the profiler. With the profiler-mode, it is a matter of your filter, whether the performance-impact is notable or not. The sampler is a much safer choice, however you have to be aware, that enabling either will trigger some hot-code-replacement which renders the system unusable for a short amount of time (and may also trigger that one: JDK7 Application is getting slow after some Uptime).

Of course, if you simply want to get basic info (memory, cpu-graph, gc and thread-count) the impact will be even lower.

How certain am I with my answer? I've been using JVisualVM, JProfiler and YourKit for almost 10 years by now. We have used sampling/monitoring mode in yourkit (which does basically the same thing than jvisualVM) in production code (a regular web-app) of our customers to analyze performance bugs. It did not have any noticable impact.

However, if you only need basic system monitoring, there might be more suitable products to consider like java melody (https://github.com/javamelody/javamelody/wiki) or kieker (http://kieker-monitoring.net/).

0
On

Yes, It does impact your JVM performance. It depends on a lot of factors. If you are simply accessing MBean attributes or invoking operations, then the impact is very little. But as soon as you start the CPU/Memory sampler or profiler it increases the impact significantly. How significantly? Let's see.

Performance impact of sampling:

Visual VM Screenshot

Connected VisualVM to a simple program which sleeps on startup (Does nothing at all). So with the main thread sleeping. I started the CPU sampler for 60 seconds. The reading for those 60 seconds for total CPU time is 5640ms (5.64 seconds).

This is when I connected using a local machine without any encryption. When you will add encryption using SSL (Which is must for production environment.) the impact will further go up.

1
On

It all depends on what you're doing with it, the actual degree of the performance impact is hard to determine.

If you're monitoring some GC via the JVM's MXBeans it has a low impact, if you're constantly monitoring it has high impact.

If you need to investigate CPU related issues, sampling provides an easy mechanism for identifying bottlenecks, with minimal effects on the performance.