Analyzer openresty-lua-phase-cpu-time
Name
openresty-lua-phase-cpu-time - OpenResty Lua Phase CPU time statistics
This analyzer collects CPU time statistics for different Lua execution phases in OpenResty-based applications. It measures the on-CPU time consumed during each request processing phase (rewrite, access, content, header_filter, body_filter, log, balancer, ssl_cert, ssl_session_store, ssl_client_hello, etc.), providing detailed breakdowns of CPU resource utilization across the request lifecycle. The analyzer helps identify CPU-intensive phases, optimize phase-specific code, and understand CPU cost distribution. Note that this measures actual CPU execution time, not wall-clock time, so I/O wait time and blocking operations are excluded.
Resource Category
Network I/O.
Application Type & Technical Stack
- OpenResty
- Kong
- APISIX
Command Line Syntax
The analyzer can be invoked directly on the command-line via the orxray
utility from the openresty-xray-cli software package.
Alternatively, the analyzer can also be invoked manually or automatically on the web console UI of OpenResty XRay (like on the Advanced web page).
# PID is the target process PID.
orxray analyzer run openresty-lua-phase-cpu-time -p PID
# trace a shell command directly
orxray analyzer run openresty-lua-phase-cpu-time -c SHELL_CMD
# PGID is the process group ID or any process's PID within the target process
# group.
orxray analyzer run openresty-lua-phase-cpu-time -p -PGID
# trace any processes started from the specified executable path.
orxray analyzer run openresty-lua-phase-cpu-time --exe /path/to/exe/file
Tracing Multiple Processes
Supported.
Output Formats
- Plain Texts
Output Example
[
{
"title": "Time Distribution of Access Phase",
"subtitle": "2 samples (min: 337 us, avg: 369 us, max: 401 us)",
"type": "dist-bar",
"ver": 1,
"series": {
"data": {"64": 0, "128": 0, "256": 2, "512": 0, "1024": 0},
"name": "samples",
"categoryUnit": "us",
"categoryTitle": "cost time"
},
"summary": {"min": 337, "max": 401, "avg": 369, "cnt": 2},
"kind": "openresty-lua-phase-time-stat"
},
{
"title": "Time Distribution of Log Phase",
"subtitle": "95 samples (min: 58 us, avg: 347 us, max: 898 us)",
"type": "dist-bar",
"ver": 1,
"series": {
"data": {"8": 0, "16": 0, "32": 1, "64": 3, "128": 17, "256": 64, "512": 10, "1024": 0, "2048": 0},
"name": "samples",
"categoryUnit": "us",
"categoryTitle": "cost time"
},
"summary": {"min": 58, "max": 898, "avg": 347, "cnt": 95},
"kind": "openresty-lua-phase-time-stat"
},
{
"title": "Time Distribution of Header filter Phase",
"subtitle": "87 samples (min: 12 us, avg: 90 us, max: 255 us)",
"type": "dist-bar",
"ver": 1,
"series": {
"data": {"2": 0, "4": 0, "8": 1, "16": 5, "32": 15, "64": 52, "128": 14, "256": 0, "512": 0},
"name": "samples",
"categoryUnit": "us",
"categoryTitle": "cost time"
},
"summary": {"min": 12, "max": 255, "avg": 90, "cnt": 87},
"kind": "openresty-lua-phase-time-stat"
},
{
"title": "Time Distribution of Balancer Phase",
"subtitle": "85 samples (min: 110 us, avg: 422 us, max: 3769 us)",
"type": "dist-bar",
"ver": 1,
"series": {
"data": {"16": 0, "32": 0, "64": 3, "128": 14, "256": 53, "512": 13, "1024": 1, "2048": 1, "4096": 0},
"name": "samples",
"categoryUnit": "us",
"categoryTitle": "cost time"
},
"summary": {"min": 110, "max": 3769, "avg": 422, "cnt": 85},
"kind": "openresty-lua-phase-time-stat"
}
]
Author
The OpenResty Inc. Team.
Copyright
Copyright (C) by OpenResty Inc. All rights reserved.