Analyzer ngx-shm-slabs
Name
ngx-shm-slabs - Slab Memory Usage in Nginx Shared Memory
This analyzer monitors slab allocator memory usage within Nginx shared memory zones in OpenResty, Kong, and Nginx applications. It captures detailed memory allocation statistics across different slab size classes (32B to 4096B) for each shared memory zone, including both free and used memory distributions. The analyzer tracks slab tree heights to detect fragmentation and generates pie charts visualizing memory distribution patterns across zones, helping identify memory waste, fragmentation issues, and optimize shared memory configuration for lua_shared_dict, proxy_cache, and other shared memory consumers.
Resource Category
Memory.
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-shm-slabs -p PID
# trace a shell command directly
orxray analyzer run ngx-shm-slabs -c SHELL_CMD
Tracing Multiple Processes
Not supported.
Output Formats
- Pie Charts
- Plain Texts
Output Example
{
"stats": {
"lock": {
"free": {"min": 32, "max": 4096, "count": 409, "sum": 1040192},
"used": {"min": 32, "max": 128, "count": 3, "sum": 192}
},
"waf": {
"free": {"min": 32, "max": 4096, "count": 2698, "sum": 10419904},
"used": {"min": 32, "max": 128, "count": 4, "sum": 320}
},
"proxycache": {
"free": {"min": 64, "max": 4096, "count": 37091, "sum": 102606400},
"used": {"min": 64, "max": 128, "count": 12788, "sum": 1636800}
},
"limit_req_shdict": {
"free": {"min": 64, "max": 4096, "count": 26957, "sum": 110036288},
"used": {"min": 64, "max": 256, "count": 131457, "sum": 23395008}
},
"ssl_session_cache": {
"free": {"min": 64, "max": 4096, "count": 17715, "sum": 64693824},
"used": {"min": 64, "max": 512, "count": 3964, "sum": 2021824}
}
},
"distributions": {
"lock": {
"free": {"32": 126, "128": 31, "4096": 252},
"used": {"32": 2, "128": 1}
},
"proxycache": {
"free": {"64": 63, "128": 12365, "4096": 24663},
"used": {"64": 1, "128": 12787}
},
"limit_req_shdict": {
"free": {"64": 63, "128": 21, "256": 11, "4096": 26862},
"used": {"64": 1, "128": 80139, "256": 51317}
}
},
"heights": {
"lock": {"min": 0, "max": 0, "avg": 0},
"waf": {"min": 1, "max": 1, "avg": 1},
"proxycache": {"min": 12, "max": 14, "avg": 13.2},
"limit_req_shdict": {"min": 16, "max": 19, "avg": 17}
},
"kind": {
"lock": "http_lua_shdict",
"waf": "http_lua_shdict",
"proxycache": "http_file_cache",
"limit_req_shdict": "http_lua_shdict"
}
}
Author
The OpenResty Inc. Team.
Copyright
Copyright (C) by OpenResty Inc. All rights reserved.