Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to generate Interactive Flame Diagram of Flink Job

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article shows you how to generate an interactive fire map of Flink assignments, which is concise and easy to understand. It will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

Preface

Flink is one of the most popular big data and streaming computing frameworks at present. Users can use Java/Scala/Python 's DataStream interface or standard SQL language to quickly implement a distributed and highly available streaming application, optimize performance through internal Java JIT, off-heap memory management and other technologies, and have complete integration of Source, Sink, WebUI, Metrics and other functions, making Flink almost become the factual standard of streaming computing.

However, when dealing with large amounts of data, it is easy to have a variety of exceptions and performance bottlenecks. When we need to optimize system performance, we often need to analyze program running behavior and performance bottlenecks. Profiling technology is a dynamic analysis method to collect program-related information when the application is running. The commonly used JVM Profiler can dynamically analyze the program from many aspects, such as CPU, Memory, Thread, Classes, GC and so on, among which CPU Profiling is the most widely used. CPU Profiling is often used to analyze the execution hotspots of code, such as "which method takes up the longest execution time of CPU", "what is the proportion of each method occupying CPU" and so on. After getting the above relevant information through CPU Profiling, R & D staff can easily analyze and optimize the hotspot bottleneck, thus break through the performance bottleneck and greatly improve the throughput of the system.

The following describes the flame diagrams we often use to optimize performance and how to integrate flame diagrams into general Flink operations.

Introduction to Flame Diagram

Flame diagram is one of the works of the author of "Top of performance" and Brendan Gregg, the author of a series of Linux system optimization tools such as DTrace, which can clearly show the function call stack of the application and the proportion of function call time. The basic principle is to sample and output logs when the program is running through a variety of agent, and use FlameGraph tools to extract the logs and output SVG images that can be viewed interactively in the browser.

Uber has opened up the jvm-profiler project to introduce how to add flame map support for Spark and Java applications, but there are no tutorials for the Flink community and the jvm-profiler official website.

In fact, any JVM-based program can use this tool, and this article will show you how to generate a flame diagram of a Flink job based on jvm-profiler.

Download and compile jvm-profilergit clone git clone https://github.com/uber-common/jvm-profiler.gitmvn clean install-DskipTests=true-Dcheckstyle.skip-Dfast-T 8C

Once compiled, copy a copy of the jvm-profiler-1.0.0.jar from the project's target directory to the flink's lib directory.

Cp target/jvm-profiler-1.0.0.jar / usr/local/flink-1.11.1/lib download FlameGraph

Since jvm-profiler supports the log files needed to generate flame images, convert logs to interactive SVG images or use Brendan Gregg's FlameGraph tool.

Git clone https://github.com/brendangregg/FlameGraph.git

Download the project source code, and then use the flamegraph.pl tool to generate the picture file.

Configure Flink

For Flink applications, we only need to inject dotted Java agent into TaskManager. For testing here, I will use the local standalone mode, modify the flink-conf.yaml file in the Flink conf directory, and add the following configuration:

Env.java.opts.taskmanager: "- javaagent:/usr/local/flink-1.11.1/lib/jvm-profiler-1.0.0.jar=sampleInterval=50"

The current minimum sampling interval is 50 milliseconds, then start the cluster and run a Flink job:

. / bin/start-cluster.sh// runs a job. / bin/flink run. / examples/streaming/StateMachineExample.jar

After running it, you can see that the stdout of TaskManager is printed as follows:

Because Java agent has been injected, the dotted data needed for the flame image will be added periodically to the standard output, then use the following command to extract the relevant logs, and use the tools provided by jvm-profiler and FlameGraph to generate the SVG image file.

/ / 1. Extract the related log cat log/flink-zhisheng-taskexecutor-0-zhisheng.out from the stdout file | grep "ConsoleOutputReporter-Stacktrace:" | awk'{print substr ($0jue 37)}'> stacktrace.json//2, execute the following command python. / stackcollapse.py-I / usr/local/flink-1.11.1/stacktrace.json > stacktrace.folded//3 in the jvm-profiler directory. Execute the following command in the FlameGraph directory to generate SVG pictures. / flamegraph.pl / Users/zhisheng/Documents/github/jvm-profiler/stacktrace.folded > stacktrace.svg

Then open the SVG image you just generated with a browser and you can see the flame picture information.

The above is how to generate interactive fire diagrams of Flink assignments. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report