How to disable buffering when using FastCGI?

Maxim Dounin mdounin at
Tue Oct 13 21:25:07 MSD 2009


On Tue, Oct 13, 2009 at 04:20:00PM +0200, Nicolas Grilly wrote:

> On Tue, Oct 13, 2009 at 13:19, Maxim Dounin <mdounin at> wrote:
> > On Tue, Oct 13, 2009 at 12:17:05PM +0200, Nicolas Grilly wrote:
> >
> >> Is there a way to disable buffering when using FastCGI? (for a Comet
> >> style application)
> >>
> >> Is there an option "fastcgi_buffering off", working like the option
> >> "proxy_buffering off" in the HTTP proxy module?
> >
> > No, there is no such option.  Buffering can't be disabled for
> > fastcgi.
> Hello Maxim,
> Is there no such option just because nobody implemented it? Or is it
> because of some kind of technical constraint?

Something like this.  FastCGI requires buffer processing which 
isn't compatible with current code for unbuffered connections.

> Do you recommend to people developing Comet style application to use
> HTTP proxying instead of FastCGI?

For now you should either close & reopen connections, or use HTTP 
proxy instead.

> Is it difficult to implement the option "fastcgi_buffering off", using
> the same technique as in the source code of module HTTP proxy?

Current "proxy_buffering off" implementation is something wierd 
and should be nuked, IMHO.  The same implementation for FastCGI 
just won't work.

I believe buffering control in upstream module (which includes 
fastcgi, proxy and memcached) should be changed to something more 
flexible.  In particular, fastcgi should be aware of FastCGI 
record boundaries, and shouldn't try to buffer too much as long as 
it got full record.

I've posted some preliminary patches for this as a part of backend 
keepalive support work, but they are a bit stale now.

Maxim Dounin

More information about the nginx mailing list