Java 1.6 JDK 工具,VisualVM
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/76042/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Java 1.6 JDK tool, VisualVM
提问by Kevin
Has anyone used the new Java 1.6 JDK tool, VisualVM, to profile a production application and how does the application perform while being profiled?
有没有人使用新的 Java 1.6 JDK 工具VisualVM来分析生产应用程序以及应用程序在被分析时的性能如何?
The documentation say that it is designed for both Production and Development use, but based on previous profiling experience, with other profiling tools, I am hesitant.
文档说它是为生产和开发使用而设计的,但根据以前的分析经验,对于其他分析工具,我很犹豫。
回答by BenCourliss
回答by hennings
For just monitoring your application, running VisualVM remotely should not slow it down much. If the system is not on the edge of collapsing, I still haven't seen any problems. It's basically just reading out information from the coarse grained built-in instrumentation of the JVM. If you start profiling, however, you'll have the same issues as with other profilers. Basically because they all work almost they same way, often using the support in the JVM.
仅仅为了监控你的应用程序,远程运行 VisualVM 应该不会减慢它的速度。如果系统没有处于崩溃的边缘,我仍然没有看到任何问题。它基本上只是从 JVM 的粗粒度内置检测中读取信息。但是,如果您开始分析,您将遇到与其他分析器相同的问题。基本上是因为它们几乎都以相同的方式工作,通常使用 JVM 中的支持。
Many people have problems with running VisualVM remotely, due to firewall issues, but you can even run Visual VM remotely over ssh, with some system properties set.
由于防火墙问题,许多人在远程运行 VisualVM 时遇到问题,但您甚至可以通过 ssh 远程运行Visual VM,并设置一些系统属性。
回答by Tim Howland
I tried it on a dev box and found that when I turned off profiling it would shut Tomcat down unexpectedly. I'd be very cautious about rolling this out to production- can you simulate load in a staging environment instead? It's not as good as the real thing, but it probably won't get you fired if it goes wrong...
我在开发箱上试了一下,发现当我关闭分析时,它会意外关闭 Tomcat。我会非常谨慎地将其推广到生产环境中 - 您可以在暂存环境中模拟负载吗?它不如真实的东西好,但如果出了问题,它可能不会让你被解雇......
回答by Kevin Peterson
I've used VisualVM before to profile something running locally. A big win was that I just start it up, and it can connect to the running JVM. It's easier to use than other profiling tools I've used before and didn't seem to have as much overhead.
我之前使用过 VisualVM 来分析本地运行的东西。一个巨大的胜利是我刚刚启动它,它可以连接到正在运行的 JVM。它比我以前使用过的其他分析工具更容易使用,而且似乎没有那么多开销。
I think it does sampling. The overhead on a CPU intensive application didn't seem significant. I didn't measure anything (I was interested in how my app performed, not how the tool performed), but it definitely didn't have the factor of 10 slowdown I'm used to seeing from profiling.
我认为它确实采样。CPU 密集型应用程序的开销似乎并不大。我没有测量任何东西(我对我的应用程序的性能感兴趣,而不是工具的性能如何),但它绝对没有我习惯于从分析中看到的 10 倍减速因素。
回答by gibbss
I've used the Net Beans profiler which uses the same underpinnings as Visual VM.
我使用了 Net Beans 分析器,它使用与 Visual VM 相同的基础。
I was working with an older version of Weblogic, which meant using the 1.5 JVM, so I couldn't do a dynamic attach. The application I was profiling had several thousand classes and my workstation was pretty much unusable while the profiler instrumented them all. Once instrumentation was complete, the system was sluggish but not completely unusable. The amount of slowdown really depends on what you need to capture. The basic CPU metrics are pretty light weight. Profiling memory allocation slows things down a lot.
我正在使用旧版本的 Weblogic,这意味着使用 1.5 JVM,所以我无法进行动态附加。我正在分析的应用程序有几千个类,而我的工作站几乎无法使用,而分析器则对它们进行了检测。仪器完成后,系统运行缓慢,但并非完全无法使用。减速的程度实际上取决于您需要捕获的内容。基本的 CPU 指标非常轻。分析内存分配会大大减慢速度。
I would not use it on a production system. Aside from the potential for slowdown, I eventually ran out of PermGen space because the profiler reinstruments and reloads classes when you change settings. (This may be fixed in the 1.6 agent, I don't know)
我不会在生产系统上使用它。除了可能会变慢之外,我最终用完了 PermGen 空间,因为当您更改设置时,探查器会重新检测并重新加载类。(这个可能在1.6代理中修复了,不知道)
回答by Matt N
It is possible to remote connect to your server from a different computer using VisualVM. You just need to right click on the "Remote" node and say "Add Remote Host."
可以使用 VisualVM 从另一台计算机远程连接到您的服务器。您只需要右键单击“远程”节点并说“添加远程主机”。
This would at least eliminate the VisualVM overhead (if there is any) from impacting performance while it is running.
这至少可以消除 VisualVM 开销(如果有的话)在运行时影响性能。
This may not eliminate all performance concerns, especially in Production environments, but it will help a little.
这可能无法消除所有性能问题,尤其是在生产环境中,但它会有所帮助。
回答by djangofan
I've been using VisualVM a lot since before it was included in the JDK. It has a negligable impact on the performance of the system. I've never noticed it cause a problem with performance on the system, but then again, our Java server had enough headroom at the time to support a little extra load. If your server is running at a level that is completely tacked out and can't handle the VisualVM running, then I would say its more likely that you need to buy another server . Any production server should have some memory headroom , otherwise what you have is a disaster just waiting to happen.
自从 VisualVM 包含在 JDK 中之前,我就一直在使用它。它对系统性能的影响可以忽略不计。我从来没有注意到它会导致系统性能出现问题,但话说回来,我们的 Java 服务器当时有足够的空间来支持一点额外的负载。如果您的服务器运行在一个完全固定的级别并且无法处理 VisualVM 的运行,那么我会说您更有可能需要购买另一台服务器。任何生产服务器都应该有一些内存空间,否则你所拥有的就是等待发生的灾难。
回答by Michael
I have used VVM(VavaVoom?) quite extensively, works like a charm in the light mode, i.e. no profiling, just getting the basic data from the VM. But once you start profiling and there are many classes, then there is considerable slowdown. I wouldn't profile in a production environment even if you have 128 core board with 2 tera of memory purely because the reloading and re-defining of the classes is tricky, the server classloaders are another thing, also vary from one server implementation to another, interfering with them in production is not a very good idea.
我已经非常广泛地使用了 VVM(VavaVoom?),在光照模式下就像一个魅力,即没有分析,只是从 VM 获取基本数据。但是一旦你开始分析并且有很多类,那么就会有相当大的放缓。即使您有 128 个核心板和 2 tera 内存,我也不会在生产环境中进行分析,这纯粹是因为重新加载和重新定义类很棘手,服务器类加载器是另一回事,从一个服务器实现到另一个服务器实现也不同,在生产中干扰它们不是一个好主意。

