Skip to main content

Command Palette

Search for a command to run...

Pinpointing the blocking/sleeping Python code paths (using OpenResty XRay)

Published
1 min read
Pinpointing the blocking/sleeping Python code paths (using OpenResty XRay)

OpenResty XRay is a non-invasive dynamic tracing product that can analyze the performance issues of any Python application. It does not require any special Python modules or special Python interpreters. We just prepared a video tutorial on YouTube: https://youtu.be/nsePw-CA1Jg It shows how to use OpenResty XRay to quickly identify the Python code paths that cause low CPU utilization. It also has subtitles.

This tutorial demonstrates step by step how to automatically analyze the running state of an online Python web application without modifying it and find out the Python code paths and line numbers that block the Python VM and OS threads. These blocking IO or sleep operations prevent the Python application from increasing CPU usage and QPS. OpenResty XRay automatically recognizes and analyzes the off-CPU flame graphs at both the Python language and the Python VM C levels and finds the most blocking code paths and lines. We also have a text version of the tutorial: https://blog.openresty.com/en/python-low-cpu/