docs/content.zh/docs/ops/debugging/profiler.md
自 Flink 1.19 起,我们基于 Flink Web UI ,用 async-profiler 交互式地分析JobManager/TaskManager 进程, 让用户可以创建具有任意间隔和事件模式的分析实例,比如 ITIMER、CPU、Lock、Wall-Clock 和 Allocation。
{{< hint warning >}}
任何测量过程本身都不可避免地会影响测量对象。为了防止对生产环境产生意外影响,分析器目前作为一项可选的功能。要启用它,你需要在[Flink配置文件]({{< ref "docs/deployment/config#flink-configuration-file" >}}) 中设置 [rest.profiling.enabled: true]({{< ref "docs/deployment/config">}}#rest-profiling-enabled) 。我们建议在开发和预生产环境中启用它,但在生产环境中应将其视为试验性功能。
{{< /hint >}}
由于分析器由async-profiler驱动,因此必须在async-profiler支持的平台上运行。
| Officially maintained builds | Other available ports | |
|---|---|---|
| Linux | x64, arm64 | x86, arm32, ppc64le, riscv64, loongarch64 |
| macOS | x64, arm64 |
在上述列表之外的平台分析将在 Message 列中报错。
Flink用户可以通过Flink Web UI方便地完成剖析提交和结果导出。
比如,
{{< img src="/fig/profiler_instance.png" class="img-fluid" width="90%" >}} {{% center %}} Profiling Instance {{% /center %}}
Failed to profiling in CPU mode: No access to perf events. Try –fdtransfer or –all-user option or ‘sysctl kernel.perf_event_paranoid=1’
这意味着 perf_event_open() 系统调用失败。默认情况下,Docker容器限制对 perf_event_open 系统调用。建议解决方案是回退到ITIMER分析模式。它类似于cpu模式,但不需要perf_events支持。它的缺点是没有内核堆栈跟踪。
Failed to profiling in Allocation mode: No AllocTracer symbols found. Are JDK debug symbols installed?
OpenJDK debug symbols 在 allocation分析模式下是必需的。 在 Installing Debug Symbols 中查看更多详细信息。
{{< hint info >}}
你可以在 Troubleshooting 页面的async-profiler中查阅更多案例。
{{< /hint >}}