Hello!
2013/8/22 wgm.china:
> 经过多方排查,发现当初为了方便调试lua的代码,把lua代码放在独立的文件中,在nginx中引用该lua文件,在nginx.conf中设置了lua_code_cache
> off,方便调试,果断注释,监控2小时,暂时正常了,请大家帮助分析一下,lua_code_cache off 是否会引起内存溢出,还是我用法有问题阿?
>
生产上应绝对避免使用 lua_code_cache off. 如果你禁用 Lua 代码缓存的话,你在启动 nginx 时应当得到下面这条警告消息:
[warn] lua_code_cache is off; this will hurt performance
看来我应该将之提高到 alert 级别?
在禁用 Lua 代码缓存时,会在每次请求时重新加载几乎所有用到的 Lua 模块,这会导致频繁地有新空间被分配,旧空间有待释放,从而很容易让
Lua 的增量式 GC 无法及时处理,造成“表观内存泄漏”。另外,你用到的某些 Lua
模块本身可能并不支持重新加载,强制重新加载时可能出现内存泄漏或者其他的问题。
最后引用一下 ngx_lua 官方文档中的相关说明:
“Disabling the Lua code cache is strongly discouraged for production
use and should only be used during development as it has a significant
negative impact on overall performance. In addition, race conditions
when reloading Lua modules are common for concurrent requests when the
code cache is disabled.”
更多细节可以参见原文:http://wiki.nginx.org/HttpLuaModule#lua_code_cache
Regards,
-agentzh
--
--
邮件来自列表“openresty”,专用于技术讨论!
订阅: 请发空白邮件到 openresty+subscribe@googlegroups.com
发言: 请发邮件到 openresty@googlegroups.com
退订: 请发邮件至 openresty+unsubscribe@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