Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add document about PassengerBufferResponse

  • Loading branch information...
commit 7353e95836634069110a89a886614ec916afeecb 1 parent ba7d62f
Ryo Onodera authored
Showing with 64 additions and 0 deletions.
  1. +64 −0 doc/Users guide Apache.txt
64 doc/Users guide Apache.txt
View
@@ -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 ===
Please sign in to comment.
Something went wrong with that request. Please try again.