Tweaking FastCGI buffers settings

Igor Sysoev igor at
Fri Nov 27 09:45:43 MSK 2009

On Fri, Nov 27, 2009 at 01:33:35AM -0500, rahul286 wrote:

> By the way if possible can somebody please answer my original question as well....
> >if my average response size is 128K and max response size is 32M and I'm on 32-bit platform,
> >then following must be most optimized configuration - It will use memory efficiently as well as will not generate any warning?
> >fastcgi_buffer_size 128K
> >fastcgi_buffers 8192 4k
> >Am I right?

Yes, a whole 32M response will be in memory, however, I do not think that
is right thing. You should handle the most responses in memory and allow
to use disk for biggest ones:

fastcgi_buffer_size 4K;
fastcgi_buffers     64 4k;

This settings store responses up to 4K+64*4K=260K in memory.

> I need to know because in some cases PHP scripts like phpMyAdmin exporting a large database generates much bigger response.
> Also in some other service I will be generating large XML output from PHP files.
> Posted at Nginx Forum:,25728,25887#msg-25887
> _______________________________________________
> nginx mailing list
> nginx at

Igor Sysoev

More information about the nginx mailing list