Re: proxy_buffering=off, potential problems? other solutions?

If response will be bigger than proxy_buffer_size, then backend will
be tied to nginx until the data will be sent to cliant.
The maximum data size that nginx can read from backend at once in this mode
is proxy_buffer_size.

maybe i’m misunderstanding something here.

as far as i see, there are 2 separate “features”:

  1. nginx reads the whole response from the proxied apache and “frees”
    apache, even when nginx is not immediately able to send it to the
    client.

  2. nginx does not start to send the response to the client until the
    whole response is read from apache (or until it has read
    “proxy_buffer_size” bytes from apache)

my problem is #2, not #1. it seems that doing a “proxy_buffering = off”
solves #2, but maybe it does also #1.

is there a way to only do #2, but not #1?

maybe it helps if i explain my situation in more detail:

the apache web-app generates a webpage dynamically, the following way:

A. generate the first part
B. do some computation
C. generate the second part

it’s very important that after step #A, the client immediately gets that
part of the webpage. with proxy_buffering enabled, it does not happen,
because nginx seems to wait for the whole response (or for enough data
to fill it’s buffers).

it seems that “proxy_buffering=off” achieves what i need. but as i
understood from your response, it also means that the apache-worker will
be blocked until the whole response is sent to the client. is there a
way to have what i need, and still have buffering enabled? :slight_smile:

(well, there is the possibility to send a lot of empty-space in the html
to fill nginx’s buffers, but that’s not a nice solution :slight_smile:

thanks,
gabor

On Wed, Feb 27, 2008 at 08:36:27AM +0100, G?bor Farkas wrote:

  1. nginx reads the whole response from the proxied apache and “frees”
    apache, even when nginx is not immediately able to send it to the client.

Yes.

  1. nginx does not start to send the response to the client until the
    whole response is read from apache (or until it has read
    “proxy_buffer_size” bytes from apache)

Yes.

my problem is #2, not #1. it seems that doing a “proxy_buffering = off”
solves #2, but maybe it does also #1.

is there a way to only do #2, but not #1?

No.

because nginx seems to wait for the whole response (or for enough data
to fill it’s buffers).

it seems that “proxy_buffering=off” achieves what i need. but as i
understood from your response, it also means that the apache-worker will
be blocked until the whole response is sent to the client. is there a
way to have what i need, and still have buffering enabled? :slight_smile:

(well, there is the possibility to send a lot of empty-space in the html
to fill nginx’s buffers, but that’s not a nice solution :slight_smile:

Yes, you are right: apache-worker will be blocked until the whole
response is sent to the client.

Initally, proxying was buffered only, because accelerator should get
response as quickly as possible and free backend.
Then non-buffered hack was added, basically to support memcached.
Then “proxy_buffering off” was appeared.
I want to rewrite all upstream code including balancers and it will
next major target after caching will be complete.