lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Sat, Mar 8, 2014 at 10:39 PM, Hao Wu wrote:
> Thanks for clarifying this, and this is what I meant. I looked up the
> ngx_lua module, it vaguely talked about how the lua state is
> maintained across the workers' process;

Just to be clear: in the ngx_lua module, the Lua VM is created in the
nginx master process before forking off the workers. So if you
(pre)compile your templates in init_by_lua, then you only need to
compile the templates once (in contrast, init_worker_by_lua runs upon
each worker process's startup, so you'll have to pre-compile the
templates for multiple times). Also, with init_by_lua, you can take
advantage of modern operating systems' Copy-On-Write (COW) feature to
further save memory :)

Best regards,