Ok, will use resty lru cache.
Thx
> On Sep 7, 2014, at 5:39 PM, "Yichun Zhang (agentzh)" <age...@gmail.com> wrote:
>
> Hello!
>
>> On Sun, Sep 7, 2014 at 7:52 AM, RJoshi wrote:
>> 2. lua-resty-lrucache and json convesion per request:
>> Do you think it would be better to retrieve rewrite mappings from database ,
>> convert into to lua string ( instead of json string) , store into
>> lua_shared_dict and also use Lua loadstring to convert into Lua table and
>> then set as a global variable per Lua VM/worker?
>
> You could. But Lua source strings are not very good for data exchange
> among different programming languages :)
>
>> Check if a Lua string exists in the cache and if yes than reuse Lua tables.
>> If not, retrieve again and override a global variable with new lua mappings
>> table.
>
> Do not use global variables unless you always provide your own global
> environment table via setfenv(). Otherwise it can pollute the global
> namespace and is a bad practice.
>
>> The reason is these mappings doesn't change very often (changes only when
>> new services are deployed on the backend) so overhead is only for the first
>> request per nginx worker and mostly done at night (low traffic).
>
> Looking good.
>
>> 5. Will try flame graf and share performance results.
>
> Looking forward to that :)
>
> Regards,
> -agentzh.