sample-bt和lj-lua-stacks不出结果,系统Ubuntu 14.04

156 views
Skip to first unread message

Heero Zhang

unread,
Aug 7, 2014, 11:19:24 PM8/7/14
to open...@googlegroups.com
我在阿里云Ubuntu 14.04上部署openresty应用,版本信息:

ngx_openresty: 1.7.2.1
系统: Ubuntu 14.04 64bit 
kernel: 3.13.0-32-generic
Systemtap: translator/driver (version 2.6/0.158, commit release-2.5-313-g8e3d1be6cf5e)
nginx-systemtap-toolkit和openresty/stapxx都是昨天pull下来的,版本未知

然后发现下列情况:

sample-bt:
WARNING: Tracing 864 (/usr/local/openresty/nginx/sbin/nginx) in user-space only...
WARNING: no or bad debug frame hdr
WARNING: No binary search table for eh frame, doing slow linear search for stap_63ea094a7fd67236ac4d1d044052733_13747
WARNING: Time's up. Quitting now...(it may take a while)
卡在Time's up. Quitting now...,等了一天也没quit,强退后bt文件size是0


lj-lua-stacks:
./stapxx/samples/lj-lua-stacks.sxx --arg time=15 --skip-badvars -x 864 > a.bt
WARNING: Start tracing 864 (/usr/local/openresty/nginx/sbin/nginx)
WARNING: Please wait for 15 seconds...
WARNING: Time's up. Quitting now...
WARNING: Found 0 JITted samples.

一开始使用ubuntu官方源的调试信息apt-get install linux-image-3.13.0-30-generic-dbgsym,然后也尝试了自己重编了内核,还是一样的情况,只能来求助了,感谢。


Yichun Zhang (agentzh)

unread,
Aug 8, 2014, 12:08:11 AM8/8/14
to openresty
Hello!

On Thu, Aug 7, 2014 at 8:19 PM, Heero Zhang wrote:
> 我在阿里云Ubuntu 14.04上部署openresty应用,版本信息:
>
> 然后发现下列情况:
>
> sample-bt:
> WARNING: Tracing 864 (/usr/local/openresty/nginx/sbin/nginx) in user-space
> only...
> WARNING: no or bad debug frame hdr
> WARNING: No binary search table for eh frame, doing slow linear search for
> stap_63ea094a7fd67236ac4d1d044052733_13747
> WARNING: Time's up. Quitting now...(it may take a while)
> 卡在Time's up. Quitting now...,等了一天也没quit,强退后bt文件size是0
>

你确定你追踪的 nginx worker 进程一直都在服务请求吗?当你的 nginx worker 进程处于空闲状态或者不够繁忙时,便会出现此种情况。

对于 lj-lua-stacks 也是类似的。

Regards,
-agentzh

Heero Zhang

unread,
Aug 8, 2014, 3:41:37 AM8/8/14
to open...@googlegroups.com
感谢回复,我可以确定是对work进程的pid,也确实用postman发了请求

sample-bt在服务器没有请求时,
 Time's up. Quitting now...是可以走过去正常退出的。
当我在15秒内去请求几个操作后,哪怕只有1个请求,Quitting now就会卡住。

尝试lj-lua-stacks时,我在15秒内发送了5个左右的请求,难道是请求数太少?但自己的服务器1个请求也能打印出来的。


在 2014年8月8日星期五UTC+8下午12时08分11秒,agentzh写道:

Heero Zhang

unread,
Aug 8, 2014, 5:01:41 AM8/8/14
to open...@googlegroups.com
我猜想我大概知道原因了
因为我的请求需要连接外网的redis服务器,而速度很慢,导致一次请求会要8秒多。

虽然发起了很多请求,可能都卡在了服务器上并未处理,实际上的采样到的请求数就会很少。
我把redis放到内网减少off-cpu的时间,就能看到少量的堆栈信息了。

也就是说虽然在lj-lua-stacks打印 Tracing后发起请求,但如果请求数很少,他也是无法采样到的?



在 2014年8月8日星期五UTC+8上午11时19分24秒,Heero Zhang写道:

jie1...@gmail.com

unread,
Aug 8, 2014, 7:23:08 AM8/8/14
to openresty
各位好。

在使用nginx配置时,有时要实现类似这样的功能:
set $no_cache  not $arg_cache;
就是当$arg_cache 为0或者空时,$no_cache为1,其它情况$no_cache为0.

但是发现nginx既不支持逻辑非操作,也不知道else, 该如何实现上面的需求?


 

smallfish

unread,
Aug 8, 2014, 10:42:13 AM8/8/14
to open...@googlegroups.com
可以用 ngx-lua 来扩展,这个也是 openresty 邮件组的主要话题。
这里的 set 指令可以参考:https://github.com/openresty/lua-nginx-module#set_by_lua 来完成逻辑判断



--
--
邮件来自列表“openresty”,专用于技术讨论!
订阅: 请发空白邮件到 openresty...@googlegroups.com
发言: 请发邮件到 open...@googlegroups.com
退订: 请发邮件至 openresty+...@googlegroups.com
归档: http://groups.google.com/group/openresty
官网: http://openresty.org/
仓库: https://github.com/agentzh/ngx_openresty
教程: http://openresty.org/download/agentzh-nginx-tutorials-zhcn.html

jie123108

unread,
Aug 8, 2014, 11:14:30 AM8/8/14
to openresty
使用ngx-lua肯定是可以的,只是为了这么小的功能点引入ngx-lua觉得有点麻烦了。 不知道有没有变通的办法,能原生的支持这个问题。
 

jie123108
 
发件人: smallfish
发送时间: 2014-08-08 22:42
主题: Re: [openresty] nginx配置里面如何支持变量的逻辑非操作?

smallfish

unread,
Aug 8, 2014, 11:41:13 AM8/8/14
to open...@googlegroups.com
多写两个if吧,如:

        location /t {
            set $no_cache 1;
            if ($arg_cache = "") {
                set $no_cache 0;
            }
            if ($arg_cache = 0) {
                set $no_cache 0;
            }
            echo $no_cache;
        }

jie123108

unread,
Aug 8, 2014, 11:49:40 AM8/8/14
to openresty
恩,看起来只能这样了,非常感谢。
 

jie123108
 
发件人: smallfish
发送时间: 2014-08-08 23:41
主题: Re: Re: [openresty] nginx配置里面如何支持变量的逻辑非操作?

Yichun Zhang (agentzh)

unread,
Aug 8, 2014, 1:35:56 PM8/8/14
to openresty
Hello!

2014-08-08 8:41 GMT-07:00 smallfish:
> 多写两个if吧,如:
>
> location /t {
> set $no_cache 1;
> if ($arg_cache = "") {
> set $no_cache 0;
> }
> if ($arg_cache = 0) {
> set $no_cache 0;
> }
> echo $no_cache;
> }
>

顺带着稍微提一下,“if 是邪恶的”:http://wiki.nginx.org/IfIsEvil :)

Regards,
-agentzh

Yichun Zhang (agentzh)

unread,
Aug 8, 2014, 1:41:56 PM8/8/14
to openresty
Hello!

2014-08-08 2:01 GMT-07:00 Heero Zhang:
> 我猜想我大概知道原因了
> 因为我的请求需要连接外网的redis服务器,而速度很慢,导致一次请求会要8秒多。
>

这种情况,你应当通过 set_keepalive() 调用启用 redis 连接池,以减少连接建立的时间。

> 虽然发起了很多请求,可能都卡在了服务器上并未处理,实际上的采样到的请求数就会很少。
> 我把redis放到内网减少off-cpu的时间,就能看到少量的堆栈信息了。
>

这两个工具都被设计成分析非常繁忙的 nginx worker 进程(CPU 使用率接近
100%,每秒处理几百、几千、乃至几万个请求)时仍然开销极小(吞吐量极限的损失低于 5%),所以你只应当你的目标 worker 进程的
CPU 使用率足够高时(至少超过 10% 吧),才能得到比较有意义的结果。它们是通过 OS 内核 tick 或者 cpu clock 探针按
CPU 时间进行分时采样的,而并不是追踪每一个具体的请求(此种做法开销很大)。

> 也就是说虽然在lj-lua-stacks打印 Tracing后发起请求,但如果请求数很少,他也是无法采样到的?
>

当然。见上面的说明。

Regards,
-agentzh
Reply all
Reply to author
Forward
0 new messages