java 如何使用 JProfiler 远程分析 Web 应用程序?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12946240/
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
How to remotely profile a web application with JProfiler?
提问by user1726942
I am running a web application that is deployed on remote machine server and I have the IP address and URL of this application. When I hit the URL with a browser, the application displays.
我正在运行一个部署在远程机器服务器上的 Web 应用程序,我有这个应用程序的 IP 地址和 URL。当我用浏览器点击 URL 时,应用程序就会显示出来。
I now have to profile that web application, as I need to find out why it is running so slow.
我现在必须分析该 Web 应用程序,因为我需要找出它运行如此缓慢的原因。
I tried using JProfiler, have not been successful. Could someone please advise how to configure JProfiler for remote profiling?
我试过用JProfiler,都没有成功。有人可以建议如何配置 JProfiler 进行远程分析吗?
回答by Ingo Kegel
The easiest way to profile a remote JVM on a system without a GUI is this:
在没有 GUI 的系统上分析远程 JVM 的最简单方法是:
- Extract the JProfiler archive (not the installer) somewhere on the remote machine
- In the installation directory call bin/jpenable and select the JVM you want to profile
- On your local machine start JProfiler and create a new session of type "Attach to profiled JVM (local or remote)"
- In the session configuration, enter the host name and the port as given by jpenable
- Start the session and profile
- 将 JProfiler 存档(不是安装程序)提取到远程机器上的某处
- 在安装目录中调用 bin/jpenable 并选择要分析的 JVM
- 在您的本地机器上启动 JProfiler 并创建一个类型为“附加到配置文件的 JVM(本地或远程)”的新会话
- 在会话配置中,输入 jpenable 给出的主机名和端口
- 开始会话和配置文件
Tip: To find a bottleneck, use sampling not instrumentation.
提示:要找到瓶颈,请使用采样而不是检测。
Update for JProfiler 10.0+
JProfiler 10.0+ 的更新
Since JProfiler 10.0, there is a remote attach feature that does not require any of the above steps, you just need SSH credentials to the remote machine.
从 JProfiler 10.0 开始,有一个不需要上述任何步骤的远程附加功能,您只需要到远程机器的 SSH 凭据。
SSH connections are made directly by JProfiler, you don't have to set up the SSH tunnel yourself. It's also possible to configure multi-hop tunnels.
SSH 连接由 JProfiler 直接建立,您不必自己设置 SSH 隧道。也可以配置多跳隧道。
JProfiler will automatically download the required agent package, upload it to the remote machine and use its command line tools to gather the information that you see in the attach dialog. The agent package is cached, so this is only done once.
JProfiler 将自动下载所需的代理程序包,将其上传到远程机器并使用其命令行工具收集您在附加对话框中看到的信息。代理程序包被缓存,因此只执行一次。
Because you have to authenticate as the same user that has started the JVM that you want to profile, it is possible to switch the user for the remote attach. For example, you can sudo to the root user to attach to a service that was started as root.
因为您必须以启动要配置文件的 JVM 的同一用户身份进行身份验证,所以可以切换用户进行远程连接。例如,您可以对 root 用户 sudo 以附加到以 root 身份启动的服务。
All the JVMs started by the selected user are shown and you can either start a full profiling session or just take a low-overhead HPROF heap dump and open it in JProfiler.
显示所选用户启动的所有 JVM,您可以启动完整的分析会话,也可以只进行低开销的 HPROF 堆转储并在 JProfiler 中打开它。