about summary refs log tree commit homepage
path: root/examples
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2011-04-29 15:48:35 -0700
committerEric Wong <normalperson@yhbt.net>2011-04-30 01:45:55 +0000
commitfe0dd93cd9cb97b46f6cfb4b1e370e38717a93f0 (patch)
tree5e5c45c385ade1bad0e0c6ec6e5eedd379181275 /examples
parentd385bc4f3ed7b783b7414f5d34299bd2bf242fe6 (diff)
downloadunicorn-fe0dd93cd9cb97b46f6cfb4b1e370e38717a93f0.tar.gz
This was broken since v3.3.1[1] and v1.1.6[2] since nginx relies on
a closed socket (and not Content-Length/Transfer-Encoding) to
detect a response completion.  We have to close the client
socket before invoking GC to ensure the client sees the response
in a timely manner.

[1] - commit b72a86f66c722d56a6d77ed1d2779ace6ad103ed
[2] - commit b7a0074284d33352bb9e732c660b29162f34bf0e

(cherry picked from commit faeb3223636c39ea8df4017dc9a9d39ac649b26d)

Conflicts:

	examples/big_app_gc.rb
	lib/unicorn/oob_gc.rb
Diffstat (limited to 'examples')
-rw-r--r--examples/big_app_gc.rb35
1 files changed, 2 insertions, 33 deletions
diff --git a/examples/big_app_gc.rb b/examples/big_app_gc.rb
index 779c3ee..c4c8b04 100644
--- a/examples/big_app_gc.rb
+++ b/examples/big_app_gc.rb
@@ -1,33 +1,2 @@
-# Run GC after every request, before attempting to accept more connections.
-#
-# You could customize this patch to read REQ["PATH_INFO"] and only
-# call GC.start after expensive requests.
-#
-# We could have this wrap the response body.close as middleware, but the
-# scannable stack is would still be bigger than it would be here.
-#
-# This shouldn't hurt overall performance as long as the server cluster
-# is at <=50% CPU capacity, and improves the performance of most memory
-# intensive requests.  This serves to improve _client-visible_
-# performance (possibly at the cost of overall performance).
-#
-# We'll call GC after each request is been written out to the socket, so
-# the client never sees the extra GC hit it. It's ideal to call the GC
-# inside the HTTP server (vs middleware or hooks) since the stack is
-# smaller at this point, so the GC will both be faster and more
-# effective at releasing unused memory.
-#
-# This monkey patch is _only_ effective for applications that use a lot
-# of memory, and will hurt simpler apps/endpoints that can process
-# multiple requests before incurring GC.
-
-class Unicorn::HttpServer
-  REQ = Unicorn::HttpRequest::REQ
-  alias _process_client process_client
-  undef_method :process_client
-  def process_client(client)
-    _process_client(client)
-    REQ.clear
-    GC.start
-  end
-end if defined?(Unicorn)
+# see {Unicorn::OobGC}[http://unicorn.bogomips.org/Unicorn/OobGC.html]
+# Unicorn::OobGC was broken in Unicorn v3.3.1 - v3.6.1 and fixed in v3.6.2