hi,章老师,请教个nginx module的问题

209 views
Skip to first unread message

Lucien Li

unread,
Apr 13, 2015, 9:56:47 PM4/13/15
to open...@googlegroups.com
章老师好:
              我现在有很多业务要处理, 我目前的架构师开发一个nginx handler模块,然后通过nginx subrequest调用自己的nginx upstream模块, upstream后端服务器是tcp server主要返回些数据~ 

nginx handler->nginx subrequest->upstream module-> tcp server

nginx handler里面主要会处理一些逻辑, 会挂载第三方的so文件处理。  然后通过subrequest 调用自己的upstream module从后端的tcp server读取数据。
据说subrequest多少会影响性能, 或者我把nginx handler逻辑都给合并到nginx upstream module。

不知道您有什么好建议,敬请期待您的回复~ 感谢了~


Message has been deleted

Yichun Zhang (agentzh)

unread,
Apr 14, 2015, 12:59:48 AM4/14/15
to openresty
Hello!

2015-04-13 19:15 GMT-07:00 Lucien Li:
>
> Nginx Handler 里面可以同时开多个SubRequest 处理吗? 我看陶辉介绍说 一个请求中,我们只能调用一次subrequest,不能一次生成多个subrequest
>

我不认识陶辉,但我知道我的 ngx_echo 模块和 ngx_lua 模块已经可靠支持 handler 发起多个串行或者并行的
subrequest 好几年了,见

https://github.com/openresty/echo-nginx-module/#echo_subrequest

https://github.com/openresty/lua-nginx-module#ngxlocationcapture

值得一提的,建议尽量不要和 nginx subrequest 打交道,使用 ngx_lua 的轻量级线程和 cosocket API
来做这种事情要灵活和简单得多(同时也有机会做得更加高效)。

Regards,
-agentzh

Lucien Li

unread,
Apr 14, 2015, 3:15:52 AM4/14/15
to open...@googlegroups.com
感谢您的回复~  我们业务比较复杂, lua可能够呛的~  所以, 还是准备把逻辑放到upstream module里面或者在结合filter module来处理, 对于需要调用第三方so文件,计算拿到结果,然后去后端tcp server上拿取数据,然后对数据进行替换解析, 是都放到upstream module里面好,还是upstream加上filter一起好呢?

在 2015年4月14日星期二 UTC+8下午12:59:48,agentzh写道:

Lucien Li

unread,
Apr 14, 2015, 3:22:02 AM4/14/15
to open...@googlegroups.com
我们都是C++写的业务逻辑~

在 2015年4月14日星期二 UTC+8下午3:15:52,Lucien Li写道:

Yichun Zhang (agentzh)

unread,
Apr 14, 2015, 11:07:36 AM4/14/15
to openresty
Hello!

2015-04-14 0:15 GMT-07:00 Lucien Li:
> 感谢您的回复~ 我们业务比较复杂, lua可能够呛的~

你应该无法想象我们使用 OpenResty/Lua 实现过的淘宝量子统计得数据服务平台以及 CloudFlare CDN/WAF/SSL
系统的业务复杂程度 :)

值得一提的是,你完全可以通过 LuaJIT 的 FFI 接口方便地整合外部的 C 库,包括第三方的 .so. 见

http://luajit.org/ext_ffi.html

早在 2009 年的时候,我也曾经向你现在一样只相信纯 C/C++ 的 nginx 模块的方式,你数一数 nginx
社区里开源的第三方模块中有多少作者里面有我的名字就可以看出来(当然,还有不少业务模块没有开源),呵呵。后来我们才发现 Lua + FFI
才是更好的解,呵呵。

祝你好运 :)

Regards,
-agentzh

Lucien Li

unread,
Apr 16, 2015, 8:51:17 PM4/16/15
to open...@googlegroups.com
感谢章老师的回复,我好好学习下~  非常感谢~


在 2015年4月14日星期二 UTC+8下午11:07:36,agentzh写道:
Reply all
Reply to author
Forward
0 new messages