Giter Site home page Giter Site logo

ngx-ai / ngx_lua_block_check Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kingluo/ngx_lua_block_check

0.0 0.0 0.0 17 KB

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).

License: BSD 2-Clause "Simplified" License

C++ 98.45% Makefile 1.55%

ngx_lua_block_check's Introduction

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

<resume begin timestamp> <resume duration> <url> <func1,src1,lineno1> <func2,src2,lineno2> <resume status>

Here the func1 is the resume entry function, while the func2 is the resume exit function.

ngx_lua_block_check's People

Contributors

kingluo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.