nchan 火焰图学习

主要是想学习下nchan nginx 模块的生命周期阶段函数,为了方便直接基于openresty+perf 搞了一个docker 镜像
方便了解nchan 的阶段处理

docker 镜像构建

具体参考github 文档, https://github.com/rongfengliang/openresty-tengine-docker/blob/master/alpine/Dockerfile-debug-njs

perf 集成

 
FROM dalongrong/openresty-tengine:debug-njs
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories && apk update && apk upgrade
RUN apk add --no-cache perf

已经构建好的镜像dalongrong/openresty-tengine:debug-njs-perf

参考使用

具体可以参考gihtub rongfengliang/openresty-nchan,对于容器运行核心是cap 能力的添加,比如如下,我为了方便直接添加的ALL
运行命令

 
sh -c " echo 0 > /proc/sys/kernel/kptr_restrict"
perf record -ag -F 99 1

docker-compose 部分配置

   app:
     image: dalongrong/openresty-tengine:debug-njs-perf
     privileged: true
     cap_add:
       - ALL
     ports:
     - "80:80"
     volumes:
     - "./nginx.conf:/usr/local/openresty/nginx/conf/nginx.conf"

效果

对于生成的perf 文件,我是基于flamescope 工具分析的,很方便火焰图生成分析工具

  • redis event 处理

从下图可以看出,实际上作者的演讲中有提到

 

 


 

 

  • pubsub 指令的处理

 

 

说明

我已经共享了一个到github 可以参考 https://github.com/rongfengliang/openresty-perf/blob/main/nchan.perf ,结合火焰图可以更好的了解nchan 的机制

参考资料

https://github.com/rongfengliang/openresty-perf
https://github.com/rongfengliang/openresty-nchan
https://www.cnblogs.com/rongfengliang/p/11350847.html
https://github.com/rongfengliang/openresty-perf/blob/main/nchan.perf

posted on   荣锋亮  阅读(91)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2020-06-05 基于纯真ip库以及openresty 模仿实现类似搜狐ip获取区域的服务
2019-06-05 puppeteer 试用
2019-06-05 My journey introducing the data build tool (dbt) in project’s analytical stacks
2019-06-05 使用singer tap-postgres 同步数据到pg
2019-06-05 comlink 是来自google chrome 团队的简化webwokers 开发的类库
2019-06-05 graphql-inspector graphql schema比较&&文档校验&&查找破坏性变动工具
2019-06-05 lyft amundsen简单试用

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示