Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kingluo/ngx_lua_block_check
This tool is used to find out long running coroutine resume, which means CPU intensive computations and/or blocking on system calls (e.g. disk read/write, os.execute).
https://github.com/kingluo/ngx_lua_block_check
blocking nginx openresty
Last synced: 2 days ago
JSON representation
This tool is used to find out long running coroutine resume, which means CPU intensive computations and/or blocking on system calls (e.g. disk read/write, os.execute).
- Host: GitHub
- URL: https://github.com/kingluo/ngx_lua_block_check
- Owner: kingluo
- License: bsd-2-clause
- Created: 2017-08-20T11:45:29.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-08-21T05:18:59.000Z (over 7 years ago)
- Last Synced: 2024-11-29T14:48:29.182Z (2 months ago)
- Topics: blocking, nginx, openresty
- Language: C++
- Homepage:
- Size: 16.6 KB
- Stars: 1
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ngx_lua_block_check
This tool is used to find out long running coroutine resume,
which means CPU intensive computations and/or blocking on system calls (e.g. disk read/write, os.execute).Long resume would cause many issues, e.g. cosocket timeout.
**Just like systemtap, this tool do not touch openresty source codes, and it is NOT nginx module too!**
**It just hooks `lua_resume()` via LD_PRELOAD to do the check.**
## Why not systemtap?
* systemtap would impact the runtime performance more or less, but this tool would not.
* it seems hard to obtain infomations inside `lua_State` via systemtap.## Compile
```
# build ngx_lua_block_check.so
make
```## Configure nginx.conf
```
# enabled or not
env NGX_LUA_BLOCK_CHECK=true;
# log threshold, in ms
env NGX_LUA_BLOCK_CHECK_MIN_MS=10;
# log file prefix
env NGX_LUA_BLOCK_CHECK_OUTPUT_FILE=/tmp/ngx_lua_block_check.log;
```if you change configs, you could reload the nginx to take effect.
## Restart openresty (only once)
```
/usr/local/openresty/bin/openresty -s stop
LD_PRELOAD=./ngx_lua_block_check.so /usr/local/openresty/bin/openresty
```## Check the log file
```
tail -f /tmp/ngx_lua_block_check.log*
``````
==> /tmp/ngx_lua_block_check.log.2282 <==
2017-08-20 23:56:44.424166 30ms /test (null),content_by_lua(nginx.conf:56),1 test,/usr/local/openresty/lualib/test.lua,7 yield==> /tmp/ngx_lua_block_check.log.2287 <==
2017-08-20 23:56:54.556875 10ms /test (null),content_by_lua(nginx.conf:56),1 test,/usr/local/openresty/lualib/test.lua,7 yield
```The log files are suffix by worker process pid.
## Log format
```
```Here the `func1` is the resume entry function, while the `func2` is the resume exit function.