4

I just moved our blog-network to ngnix (from apache) which is powered by WPMU. Everything is running smoothly and fine.

During my quest to optimize server to the max level - I came across this thread on nginx forum http://forum.nginx.org/read.php?2,2649

I would really like to know: Answer to the original question...

For example, to prevent the warning when serving a 6144 kilobyte file, which of the three methods would yield the best performance?

  1. A large number of small buffers: fastcgi_buffers 768 8k
  2. A small number of large buffers: fastcgi_buffers 8 768k
  3. A near balance between the buffers and size: fastcgi_buffers 64 96k

And also one more thing: In my ngnix.config - my setting is:

fastcgi_buffers 64 4k;

i.e. 256K buffer size (I am on 32-bit platform). Does this mean if my PHP scripts generates response larger than 256K, nginx will throw some error?

I know ngnix forum seems better place to ask this but as no ngnix forum is more active than serverfault, I'm posting this question here.

I hope I will get some inputs/guidance from experts here.

Thanks,

-Rahul

1 Answer 1

5

No, it means that if your scripts often generate less than 256K responses - the buffer will often be half-empty, and you just waste the memory :)

Beffer works like this: nginx reads min(buffer_size,response_size) bytes from FCGI script, sends it to a client and empties the buffer's contents. If there's more responce data - it reads & sends again.

If your site often provides small script-generated pages, the optimal value is a bit more than the size of a typical script responce size: headers + contents.

3
  • Thanks. It really gives me useful hints. Now I guess warnings i.e. [warn] lines, we see in ngnix error_log regarding FCGI buffer are generated when ngnix does read & send again multiple times. Can it be safely ignored? Also if possible please answer my first question too. Thanks. :-)
    – rahul286
    Nov 26, 2009 at 7:07
  • The warning means nginx tried to fetch the whole response and it did not fit into the buffer. This is not good unless happens not so frequent: disk is slow, you should avoid using it instead of buffering.
    – kolypto
    Nov 26, 2009 at 13:00
  • Thanks. I got answer to this from Igor (creator of nginx) himself as well. You further made it clear to me. :-)
    – rahul286
    Nov 29, 2009 at 12:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .