Groups
Groups
Sign in
Groups
Groups
openresty
Conversations
Labels
About
Send feedback
Help
关于lua代码热更新及rpc服务的讨论
86 views
Skip to first unread message
ZIHENG YU
unread,
May 19, 2025, 8:24:59 AM
May 19
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to openresty
各位大佬,有个问题想请教下:我们现在的技术架构使用了nginx+Openresty,有一些高频变更的业务逻辑是通过Lua实现的;
而二进制的迭代更新导致我们的服务器升级耗时是比较长的,且nginx的reload或upgrade会导致进程重启,所以就想了两条思路来改善这种情况:
1.
把已有的Openresty上业务逻辑做解耦拆分,在本地搭建一个独立的rpc服务,后续需要改动业务代码时,只重启rpc服务即可
;
我们现有的业务逻辑会依赖大量的ngx.var类型的变量读取和修改动作,做rpc调用似乎会带来很大的开销,主要在序列化、反序列化及网络传输的开销;;
且现在并没有适用于lua的rpc协议选型;
2.
支持不重启进程加载lua代码
:我们有调研过该会话
https://groups.google.com/g/openresty/c/aQY-Fo517qw/m/z8aD8LdJEgAJ
,并验证成功。
但版本的管理似乎是一个复杂的情况,在生产环境中不好判断实际执行的lua逻辑是哪一个版本?毕竟package.loaded.module_name的更新并不是一个非常清楚的事件。
并且如果代码改动较底层的lua文件,需要重载入很多调用它的代码,这个改动面难以控制,(父文件里有缓存局部变量 local tmp_var = require('module')的用法 );
希望各位大佬能给点输入,给点建议,tks,^_^
kurapi...@gmail.com
unread,
Jun 25, 2025, 11:01:24 AM
Jun 25
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to openresty
我的做法比较复杂,首先我有一个套OOP系统,其中类是可以重复定义,但每次得到一个新版本类。每次api请求,都构建一个类对象进行实际处理。这时候如果更新类,不会导致旧对象功能被修改。而下次访问使用新版本类的对象来进行处理。
Reply all
Reply to author
Forward
0 new messages