Question: http video streaming and nginx ram usage

Maxim Dounin mdounin at mdounin.ru
Wed Mar 9 14:55:39 MSK 2011


Hello!

On Tue, Mar 08, 2011 at 12:15:23AM -0500, birdy wrote:

> I'm using Nginx to forward incoming http requests (from the Internet) to
> an Aviosys 9100A+ (low-cost) IP video server.

[...]

> As I wrote, In my setup, I reverse-proxy only the allowed URLs (i.e. the
> ones to "get the video") on to the video server with nginx. This works
> fine, but nginx seems to buffer the http data that it forwards locally.
> So while viewing the video stream, nginx consumes more and more RAM
> until the little linux device crashes. 
> 
> However, if I stop viewing the stream after 1 or 2 minutes, before RAM
> runs out, the memory gets freed again.
> I believe it frees the ram because the request is finished.

nginx frees (most of) memory allocated for request only when 
request is finished, this is how it's expected to work.

Known issue with long-running requests is that chunked filter will 
allocate some small amount of memory for each chunk send, and this 
may grow big enough for long-running requests with "proxy_buffering" 
set to "off".

Workaround is

    chunked_transfer_encoding off;

as available in nginx 0.8.35+.

Maxim Dounin

p.s. As already pointed out, your config isn't correct.  Location 
directive can't be used to test query string arguments.  This is 
irrelevant though.



More information about the nginx mailing list