38 Video Cunningly Using 'Wrk' and Flame Graphs to Pinpoint Performance Bottlenecks

38 Video- Cunningly Using ‘wrk’ and Flame Graphs to Pinpoint Performance Bottlenecks #

Hello, I’m Wen Ming.

Today is the final video lesson in our series. The remaining content will be presented in text and image format. As usual, in order to learn more effectively, I would like to ask you a few questions before you start watching the video:

  • Have you tested the performance of OpenResty programs? How can you scientifically identify performance bottlenecks?
  • How can you understand the information presented in a flame graph and relate it to Lua code?

These questions are the core topics that will be addressed in today’s video lesson. I hope you can take a moment to think about them and bring your questions to the study of today’s video content.

At the same time, I will provide corresponding text explanations to help you summarize and review the content after watching the video. Below is the written introduction for today’s lesson.

Today’s Focus #

In today’s video lesson, I will demonstrate how to optimize code using the open-source project “lua-performance-demo” along with the wrk tool and flame graphs. The project can be found at: https://github.com/iresty/lua-performance-demo.

The environment used in the video is Ubuntu 16.04. The systemtap and wrk tools are installed using apt-get, so I don’t recommend installing them from source.

The demo includes several versions, and I will use wrk to test the QPS (queries per second) for each version. During the testing process, I will use stapxx to generate flame graphs, which will guide us in optimizing specific functions and code blocks.

In the end, we will see a version with a performance improvement of over 10 times. Of course, the optimization methods mentioned in the previous lessons of this column will be used. I suggest that you clone this demo project to reproduce the operations I show in the video and deepen your understanding of wrk, flame graphs, and performance optimization.

It’s important to note that performance optimization is not based on intuition and perception, but requires scientific data for guidance. The data here includes not only the final performance indicators such as QPS, but also using data to locate specific bottlenecks.

Course Materials Reference #

Today’s course materials have been uploaded to my GitHub. You can download them and study on your own.

The link is as follows: https://github.com/iresty/geektime-slides

If there is anything unclear, you can ask questions in the comments section, and you can also share your learning experience there. Looking forward to conversing with you, and feel free to share this article with your colleagues and friends. Let’s communicate and make progress together.