unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
From: Eric Wong <normalperson@yhbt.net>
To: mongrel-unicorn@rubyforge.org
Cc: Aaron Patterson <aaron@tenderlovemaking.com>
Subject: [PATCH 1/2] examples/nginx.conf: clarify proxy_buffering for Rails 3.1
Date: Wed, 27 Apr 2011 14:12:41 -0700	[thread overview]
Message-ID: <1303938762-32318-2-git-send-email-normalperson@yhbt.net> (raw)
In-Reply-To: <1303938762-32318-1-git-send-email-normalperson@yhbt.net>

I've tested with nginx 1.0.0 and confirmed "proxy_buffering off;"
can cause Unicorn to block on a slow client reading a
large response.  While there's a potential (client-visible)
performance improvement with Rails 3.1 streaming responses, it
can also hurt the server with slow clients.

Rainbows! with (ThreadSpawn or ThreadPool) is probably the best
way to do streaming responses efficiently from all angles (from
a server, client and programmer time perspective).
---
 examples/nginx.conf |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/examples/nginx.conf b/examples/nginx.conf
index 52ec245..9f245c8 100644
--- a/examples/nginx.conf
+++ b/examples/nginx.conf
@@ -125,10 +125,15 @@ http {
       proxy_redirect off;
 
       # set "proxy_buffering off" *only* for Rainbows! when doing
-      # Comet/long-poll stuff.  It's also safe to set if you're
-      # using only serving fast clients with Unicorn + nginx.
-      # Otherwise you _want_ nginx to buffer responses to slow
-      # clients, really.
+      # Comet/long-poll/streaming.  It's also safe to set if you're using
+      # only serving fast clients with Unicorn + nginx, but not slow
+      # clients.  You normally want nginx to buffer responses to slow
+      # clients, even with Rails 3.1 streaming because otherwise a slow
+      # client can become a bottleneck of Unicorn.
+      #
+      # The Rack application may also set "X-Accel-Buffering (yes|no)"
+      # in the response headers do disable/enable buffering on a
+      # per-response basis.
       # proxy_buffering off;
 
       proxy_pass http://app_server;
-- 
Eric Wong

_______________________________________________
Unicorn mailing list - mongrel-unicorn@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying


  reply	other threads:[~2011-04-27 21:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-27 18:13 Rails streaming example video Eric Wong
2011-04-27 21:12 ` [PATCH 0/2] attempting to clarify docs for streaming Eric Wong
2011-04-27 21:12   ` Eric Wong [this message]
2011-04-27 21:12   ` [PATCH 2/2] configurator: attempt to clarify :tcp_nopush/:tcp_nodelay Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://yhbt.net/unicorn/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1303938762-32318-2-git-send-email-normalperson@yhbt.net \
    --to=normalperson@yhbt.net \
    --cc=aaron@tenderlovemaking.com \
    --cc=mongrel-unicorn@rubyforge.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhbt.net/unicorn.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).