问题描述:
收到一个请求,解析一下内容构造成lua的一个table T,假设有a b c d四个属性, a b c是一些共有属性, d是一个数组,会遍历d然后构造多个子请求调用ngx.location.capture_multi 并行的处理d, a b c也需要传递给子请求,这时候是用ctx 把T传递过去,然后在子请求内用ngx.ctx去取值处理;还是把要传递的值包在body 或者 args中传给子请求?
lua-nginx-module上看到:
The ngx.ctx lookup requires relatively expensive metamethod calls and it is much slower than explicitly passing per-request data along by your own function arguments. So do not abuse this API for saving your own function arguments because it usually has quite some performance impact.
大量使用ngx.ctx应该会影响性能