Nginx-LuaJIT core
agentzh
agentzh at gmail.com
Wed May 11 08:20:18 MSD 2011
On Wed, May 11, 2011 at 6:18 AM, Umesh Sirsiwal <usirsiwal at verivue.com> wrote:
> I have not yet run the nginx with valgrind. However, changing the original
> lua file to the following fixes the issue. It turns out the output can be
> 100MB+. I will keep digging.
>
> local prox = 3201
> local nrAgent = 8
> ngx.print("coblitzstat\n")
> for p = prox, prox+nrAgent-1 do
> local l = "/prox" .. p .. ngx.var['request_uri']
> print("copass: fetching location " .. l)
> local res = ngx.location.capture(l)
>
> if (res.status ~= ngx.HTTP_OK and res.status ~= 504) then
> return(res.status)
> end
> if(res.status == ngx.HTTP_OK and string.len(res.body)> 0) then
> ngx.print(res.body)
> end
> end
>
Just a side note: calling ngx.print() right after
ngx.location.capture() in your loop is strongly recommended because
for HTTP 1.1 requests, the upstream and downstream (non-blocking)
network I/O can be overlapped very well in this scenario, thus
increasing the overall throughput, reducing response latency, and
decreasing memory use on the server side :)
For HTTP 1.0 requests, where ngx_lua will automatically buffer all the
outputs on the C level in order to obtain the response length and make
up a proper Content-Length header for the HTTP 1.0 response.
Thank you for digging into this issue ;)
Best,
-agentzh
More information about the nginx-devel
mailing list