Skip to content

Commit

Permalink
add document about PassengerBufferResponse
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryo Onodera committed Nov 16, 2011
1 parent ba7d62f commit 7353e95
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions doc/Users guide Apache.txt
Expand Up @@ -923,6 +923,70 @@ allow the attacker to cause a Denial-of-Service.
You can prevent this from happening by pointing PassengerRestartDir to a
directory that's readable by Apache, but only writable by administrators.

[[PassengerBufferResponse]]
=== PassengerBufferResponse <on|off> ===
When turned on, application-generated responses are buffered in memory. By buffering
responses, protection is provided against slow HTTP clients that can not read your
response immediately.

For example, consider an HTTP client that's on a dial-up modem link, and your
application instance generates a 2 MB response. If response buffering is turned
off then your application instance will be blocked until the entire 2 MB has been
sent out to the HTTP client. This disallows your application instance to do any useful
work in the mean time. By enabling response buffering, Phusion Passenger will read
the application response as quickly as possible and will take care of slow clients.

However, keep in mind that enabling this option will make streaming responses
impossible. Consider for example this piece of Rails code:

--------------------------------
render :text => lambda { |response, output|
10.times do |i|
output.write("entry #{i}\n")
output.flush
sleep 1
end
}
--------------------------------

...or this piece of Rack code:

--------------------------------
class Response
def each
10.times do |i|
yield("entry #{i}\n")
sleep 1
end
end
end

app = lambda do |env|
[200, { "Content-Type" => "text/plain" }, Response.new]
end
--------------------------------

When response buffering is turned on, Phusion Passenger will wait until
the application is done sending the entire response before forwarding it
to the client. The client will not receive anything for 10 seconds,
after which it receives the entire response at once.
When response buffering is turned off, it works as expected: the client
receives an "entry X" message every second for 10 seconds.

This option may occur in the following places:

* In the global server configuration.
* In a virtual host configuration block.
* In a `<Directory>` or `<Location>` block.
* In '.htaccess'.

In each place, it may be specified at most once. The default value is 'on'.

[NOTE]
=====================================================
The <<PassengerBufferResponse,PassengerBufferResponse>> directive should be turned off
if responses can be huge. Because entire responses are buffered in memory when turned on.
=====================================================

=== Security options ===

Expand Down

0 comments on commit 7353e95

Please sign in to comment.