Analyzer ngx-slowest-config-re
Name
ngx-slowest-config-re - Slowest Regular Expression in Nginx Rewrite or Find Config
This analyzer identifies the slowest regular expression operations in Nginx configuration files, including rewrite rules and location matching patterns. It profiles regex execution time during configuration parsing and request processing, capturing the regex patterns and their maximum latency when operations exceed the specified threshold. The analyzer generates performance reports that help identify inefficient regex patterns that may cause CPU bottlenecks, enabling optimization of Nginx configuration for better performance in OpenResty, Kong, APISIX, and standard Nginx deployments.
Resource Category
CPU.
Application Type & Technical Stack
- OpenResty
- Nginx
- 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 ngx-slowest-config-re -p PID
# trace a shell command directly
orxray analyzer run ngx-slowest-config-re -c SHELL_CMD
# PGID is the process group ID or any process's PID within the target process
# group.
orxray analyzer run ngx-slowest-config-re -p -PGID
# trace any processes started from the specified executable path.
orxray analyzer run ngx-slowest-config-re --exe /path/to/exe/file
Tracing Multiple Processes
Supported.
Output Formats
- Bar Charts
- Plain Texts
Output Example
[
{
"series": {
"data": {
"base64:XC4oanBnfGpwZWd8cG5nfGdpZnx3ZWJwKSQ=": 11854, // The regex is base64 as value
"base64:XC5waHAk": 27617
},
"name": "Max Latency (ns)"
},
"type": "bar",
"title": "Slowest Patterns in Rewrite and Location Rules"
}
]
Author
The OpenResty Inc. Team.
Copyright
Copyright (C) by OpenResty Inc. All rights reserved.