about summary refs log tree commit homepage
path: root/lib/rainbows.rb
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-11-18 00:08:52 -0800
committerEric Wong <normalperson@yhbt.net>2009-11-18 00:08:52 -0800
commit77f930cb64d32b3fac942b462cf4c7a04af730e3 (patch)
tree6612d92c7d3681f0701969db5060afd6c65c62e0 /lib/rainbows.rb
parent02245b9ea8a407ac67a9633119140fa2fd2c561e (diff)
downloadrainbows-77f930cb64d32b3fac942b462cf4c7a04af730e3.tar.gz
And change the default to 2 seconds, most clients can
render the page and load all URLs within 2 seconds.
Diffstat (limited to 'lib/rainbows.rb')
-rw-r--r--lib/rainbows.rb11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/rainbows.rb b/lib/rainbows.rb
index 4686f2b..3fed331 100644
--- a/lib/rainbows.rb
+++ b/lib/rainbows.rb
@@ -6,7 +6,7 @@ module Rainbows
   # global vars because class/instance variables are confusing me :<
   # this struct is only accessed inside workers and thus private to each
   # G.cur may not be used the network concurrency model
-  class State < Struct.new(:alive,:m,:cur,:server,:tmp)
+  class State < Struct.new(:alive,:m,:cur,:kato,:server,:tmp)
     def tick
       tmp.chmod(self.m = m == 0 ? 1 : 0)
       alive && server.master_pid == Process.ppid or quit!
@@ -18,7 +18,7 @@ module Rainbows
       false
     end
   end
-  G = State.new(true, 0, 0)
+  G = State.new(true, 0, 0, 2)
 
   require 'rainbows/const'
   require 'rainbows/http_server'
@@ -43,6 +43,7 @@ module Rainbows
   #   Rainbows! do
   #     use :Revactor # this may also be :ThreadSpawn or :ThreadPool
   #     worker_connections 400
+  #     keepalive_timeout 0 # zero disables keepalives entirely
   #   end
   #
   #   # the rest of the Unicorn configuration
@@ -53,6 +54,12 @@ module Rainbows
   # each of them.  The total number of clients we're able to serve is
   # +worker_processes+ * +worker_connections+, so in the above example
   # we can serve 8 * 400 = 3200 clients concurrently.
+  #
+  # The default is +keepalive_timeout+ is 2 seconds, which should be
+  # enough under most conditions for browsers to render the page and
+  # start retrieving extra elements for.  Increasing this beyond 5
+  # seconds is not recommended.  Zero disables keepalive entirely
+  # (but pipelining fully-formed requests is still works).
   def Rainbows!(&block)
     block_given? or raise ArgumentError, "Rainbows! requires a block"
     HttpServer.setup(block)