Buffers, PHP-FastCGI and nginx

Am I correct in assuming I’ll get the best performance from my nginx+php
setup if I:

  • set PHP’s output_buffering to 4096
  • set PHP’s zlib.output_compression to On
  • set nginx’s fastcgi_buffers to the same number of php instances, and
    to a size of 4k
  • set nginx’s client_body_buffer_size to 4k
  • set nginx to gzip everything if the client accepts it

Phillip B Oldham
The Activity People
[email protected] mailto:[email protected]


Policies

This e-mail and its attachments are intended for the above named
recipient(s) only and may be confidential. If they have come to you in
error, please reply to this e-mail and highlight the error. No action
should be taken regarding content, nor must you copy or show them to
anyone.

This e-mail has been created in the knowledge that Internet e-mail is
not a 100% secure communications medium, and we have taken steps to
ensure that this e-mail and attachments are free from any virus. We must
advise that in keeping with good computing practice the recipient should
ensure they are completely virus free, and that you understand and
observe the lack of security when e-mailing us.

On Mon, Jun 23, 2008 at 05:20:34PM +0100, Phillip B Oldham wrote:

Am I correct in assuming I’ll get the best performance from my nginx+php
setup if I:

  • set PHP’s output_buffering to 4096
  • set PHP’s zlib.output_compression to On

You should turn PHP’s zlib.output_compression off.

  • set nginx’s fastcgi_buffers to the same number of php instances, and
    to a size of 4k

No, fastcgi_buffers is per connection. For example, if

fastcgi_pass 8 4k;

then each FastCGI connection may use up to 8 buffers.

You should set fastcgi_buffers to correspond to a typical response size.

  • set nginx’s client_body_buffer_size to 4k

Probably, no. You should set it bigger, something about 64K or 128K to
avoid buffering to tempoarary file.

  • set nginx to gzip everything if the client accepts it

Yes.