Hey guys,
First of all, thanks agentzh for the project and work here. We love OpenResty and are excited to use it even more. Now to my questions... Both a very generic and not a bug or issue with OpenResty per se.
We are using OpenResty + lua-nginx-module on a small hosting with a few thousand sites and started to notice an increase in memory utilization after we started to use Lua more often. Wondering if you guys have a good strategy or recommendation to improve our flow.
Basically, each site has a server {} block with multiple location {} blocks inside, like this:
location /1 {
access_by_lua_file /home/clientX/lua/include1.lua
}
location /wp-admin {
access_by_lua_file /home/clientX/lua/wp-admin.lua
}
location /2...
location /3..
location /
{
access_by_lua_file /home/clientX/lua/generic.lua
}
Inside each block, we include the access_by_lua_file with slight different code, depending on the user case. So at the end, we have a few thousand entries of:
access_by_lua_file /home/clientX/lua/code.lua
access_by_lua_file /home/client1/lua/code.lua
access_by_lua_file /home/client2/lua/code.lua
..
Most of the with the exact code.lua content, just on different files (only a few are different).
My questions:
1- Is that a good approach? Do you guys see any issues there?
2- Most clients have the exact same lua code. If we used /home/generic/lua/code.lua (instead of /home/clientX) for the majority of location/server blocks, instead of having one different file per client, does that affect the memory footprint?
I mean, how does openresty / the lua module handles memory if the same file is included as "access_by_lua_file" across multiple location & server blocks? Will it reuse the memory or allocate it separately for each? It complicates our setup a bit more, but if it gives better performance, we might change our approach.
3- Is there any performance gain by including multiple lua files or would it be better to concatanate all of them together into one big lua file? I mean, it is better to do:
access_by_lua_file small1.lua
access_by_lua_file small2.lua
access_by_lua_file small3.lua
Or
access_by_lua_file big.lua (with all small* files together)?
Too many questions, but thanks for the help.