Buffer Reuse in Nginx

Alexandr Gomoliako zzz at zzz.org.ua
Tue Mar 6 16:28:20 UTC 2012


On 3/6/12, Soares Chen <soares.chen at gmail.com> wrote:
> I am trying to write an Nginx module that receive input and produce
> output in streaming fashion over long lasting connection. Due to the
> nature of the connection, I can't wait for all the buffers to be
> reclaimed at the end of the request, as that would potentially cause
> high memory consumption to the server. As a result, I am looking for
> ways to determine if buffers sent through ngx_http_output_filter() are
> safe to be reused.

There is another way: you can skip ngx_http_output_filter() altogether
and use r->connection directly with c->send/c->recv and your own
handlers for c->read/c->write.

This will be much easier with perl though. I didn't document it very
well, but I'm willing to help you, if you are going to use this:
http://zzzcpan.github.com/nginx-perl/Nginx.html#CONNECTION_TAKEOVER



More information about the nginx-devel mailing list