unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
* Rails streaming example video
@ 2011-04-27 18:13 Eric Wong
  2011-04-27 21:12 ` [PATCH 0/2] attempting to clarify docs for streaming Eric Wong
  0 siblings, 1 reply; 4+ messages in thread
From: Eric Wong @ 2011-04-27 18:13 UTC (permalink / raw)
  To: mongrel-unicorn; +Cc: Aaron Patterson

Aaron Patterson gladly provided us with a streaming video which I've
agreed to host:

http://unicorn.bogomips.org/streaming.ogv

If anybody has more Unicorn/Rainbows!-related videos/slides/etc in Free
Software-friendly formats, I'd be more than glad to host or mirror them.

Thanks Aaron!

-- 
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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 0/2] attempting to clarify docs for streaming
  2011-04-27 18:13 Rails streaming example video Eric Wong
@ 2011-04-27 21:12 ` Eric Wong
  2011-04-27 21:12   ` [PATCH 1/2] examples/nginx.conf: clarify proxy_buffering for Rails 3.1 Eric Wong
  2011-04-27 21:12   ` [PATCH 2/2] configurator: attempt to clarify :tcp_nopush/:tcp_nodelay Eric Wong
  0 siblings, 2 replies; 4+ messages in thread
From: Eric Wong @ 2011-04-27 21:12 UTC (permalink / raw)
  To: mongrel-unicorn; +Cc: Aaron Patterson

Since streaming responses is becoming a topic nowadays, I figure we
should attempt to clarify configuration options relevant to it.

In general, I think the defaults for both Unicorn and Rainbows!  in
their targeted environments are reasonable and do not need more tuning.

I've pushed out the following two patches to
git://bogomips.org/unicorn.git:

* [PATCH 1/2] examples/nginx.conf: clarify proxy_buffering for Rails
* [PATCH 2/2] configurator: attempt to clarify

Feedback is greatly appreciated as always.

-- 
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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] examples/nginx.conf: clarify proxy_buffering for Rails 3.1
  2011-04-27 21:12 ` [PATCH 0/2] attempting to clarify docs for streaming Eric Wong
@ 2011-04-27 21:12   ` Eric Wong
  2011-04-27 21:12   ` [PATCH 2/2] configurator: attempt to clarify :tcp_nopush/:tcp_nodelay Eric Wong
  1 sibling, 0 replies; 4+ messages in thread
From: Eric Wong @ 2011-04-27 21:12 UTC (permalink / raw)
  To: mongrel-unicorn; +Cc: Aaron Patterson

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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] configurator: attempt to clarify :tcp_nopush/:tcp_nodelay
  2011-04-27 21:12 ` [PATCH 0/2] attempting to clarify docs for streaming Eric Wong
  2011-04-27 21:12   ` [PATCH 1/2] examples/nginx.conf: clarify proxy_buffering for Rails 3.1 Eric Wong
@ 2011-04-27 21:12   ` Eric Wong
  1 sibling, 0 replies; 4+ messages in thread
From: Eric Wong @ 2011-04-27 21:12 UTC (permalink / raw)
  To: mongrel-unicorn; +Cc: Aaron Patterson

These options will probably be more important as interest in
streaming responses in Rails 3.1 develops.

I consider the respective defaults for Unicorn (designed to run
behind nginx) and Rainbows! (designed to run standalone) to be
the best choices in their respective environments.
---
 lib/unicorn/configurator.rb |   22 +++++++++++++++-------
 1 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/lib/unicorn/configurator.rb b/lib/unicorn/configurator.rb
index 73869de..bed3abe 100644
--- a/lib/unicorn/configurator.rb
+++ b/lib/unicorn/configurator.rb
@@ -253,24 +253,32 @@ class Unicorn::Configurator
   #
   # [:tcp_nodelay => true or false]
   #
-  #   Disables Nagle's algorithm on TCP sockets if +true+
+  #   Disables Nagle's algorithm on TCP sockets if +true+.
+  #
+  #   Setting this to +true+ can make streaming responses in Rails 3.1
+  #   appear more quickly at the cost of slightly higher bandwidth usage.
+  #   The effect of this option is most visible if nginx is not used,
+  #   but nginx remains highly recommended with \Unicorn.
   #
   #   This has no effect on UNIX sockets.
   #
-  #   Default: operating system defaults (usually Nagle's algorithm enabled)
+  #   Default: +false+ (Nagle's algorithm enabled) in \Unicorn,
+  #   +true+ in Rainbows!
   #
   # [:tcp_nopush => true or false]
   #
   #   Enables/disables TCP_CORK in Linux or TCP_NOPUSH in FreeBSD
   #
-  #   This is enabled by default as of Unicorn 3.4.  This prevents partial
-  #   TCP frames from being sent out and reduces wakeups in nginx if it is
-  #   on a different machine.  Since Unicorn is only designed for applications
-  #   that send the response body quickly without keepalive, sockets will
-  #   always be flushed on close to prevent delays.
+  #   This prevents partial TCP frames from being sent out and reduces
+  #   wakeups in nginx if it is on a different machine.  Since \Unicorn
+  #   is only designed for applications that send the response body
+  #   quickly without keepalive, sockets will always be flushed on close
+  #   to prevent delays.
   #
   #   This has no effect on UNIX sockets.
   #
+  #   Default: +true+ in \Unicorn 3.4+, +false+ in Rainbows!
+  #
   # [:tries => Integer]
   #
   #   Times to retry binding a socket if it is already in use
-- 
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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-04-27 21:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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   ` [PATCH 1/2] examples/nginx.conf: clarify proxy_buffering for Rails 3.1 Eric Wong
2011-04-27 21:12   ` [PATCH 2/2] configurator: attempt to clarify :tcp_nopush/:tcp_nodelay Eric Wong

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).