about summary refs log tree commit homepage
path: root/Static_Files
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2010-07-10 07:26:33 +0000
committerEric Wong <normalperson@yhbt.net>2010-07-10 07:29:22 +0000
commit9838b614621bbbff27a91166406d833be85adbbd (patch)
tree6fbf0e6805b88f0490068d6aecebcbbc7dbf3386 /Static_Files
parent59f10a6dcf895b728bbc34546aebdb8bf25a1b0b (diff)
downloadrainbows-9838b614621bbbff27a91166406d833be85adbbd.tar.gz
Some folks may be interested in setting up Rainbows!
as a static file server.
Diffstat (limited to 'Static_Files')
-rw-r--r--Static_Files71
1 files changed, 71 insertions, 0 deletions
diff --git a/Static_Files b/Static_Files
new file mode 100644
index 0000000..ff27460
--- /dev/null
+++ b/Static_Files
@@ -0,0 +1,71 @@
+= Static file serving with \Rainbows!
+
+While Ruby application servers aren't traditionally used to serve static
+files, it'll be fun for us to see how far we can go with \Rainbows!
+
+We aren't delusional enough (yet :) to compete with C-based servers like
+nginx or lighttpd in terms of raw performance, but wouldn't it be nice
+to simplify your deployments and only deploy one server?
+
+== {sendfile}[http://rubygems.org/gems/sendfile] RubyGem
+
+To enable the "sendfile" gem, just make sure you have 1.0.0 or later and
+"require" it in your Rainbows!/Unicorn config file (not your Rack
+config.ru):
+
+    require 'sendfile' # that's it! nothing else to do
+
+    # the rest of you Rainbows! config goes below:
+    worker_processes 4
+    stderr_path "/var/log/app/rainbows.err.log"
+    Rainbows! do
+      use :RevFiberSpawn
+      worker_connections 100
+    end
+
+The sendfile gem is works for all of our concurrency models except
+Revactor, NeverBlock and EventMachine (see below).
+
+The sendfile gem is less buggy than current (Ruby 1.9.2-rc1)
+IO.copy_stream and supports FreeBSD and Solaris in addition to Linux.
+This RubyGem also works under Ruby 1.8 (even with threads) and should
+work with rubinius.git, too.
+
+\Rainbows! supports the sendfile gem since v0.95.0
+
+== IO.copy_stream (Ruby 1.9 only)
+
+Users of pure-Ruby Thread-based models ThreadPool, ThreadSpawn, and
+their Writer* variants use the core IO.copy_stream method under Ruby
+1.9.  IO.copy_stream uses sendfile() under Linux, and a pread()/write()
+loop (implemented in C) on other systems.
+
+IO.copy_stream under Linux with Ruby 1.9.2-rc1 (and before) is also
+subject to hanging indefinitely when a client disconnected prematurely.
+This issue is fixed in Ruby trunk (July 2010) and will be in the next
+Ruby 1.9.2 release.
+
+\Rainbows! supports IO.copy_stream since v0.93.0
+
+== EventMachine FileStreamer
+
+EventMachine and NeverBlock users automatically take advantage of
+the mmap()-based FileStreamer class distributed with EventMachine.
+
+\Rainbows! supports EventMachine FileStreamer since v0.4.0
+
+== Performance
+
+With large files and high-throughput clients, there should be little
+performance difference compared to optimal C implementation such as
+nginx and lighttpd.  Ruby runtime overhead matters more when serving
+slower clients and smaller files.
+
+== The Future...
+
+Future releases of \Rainbows! will have byte-range support to serve
+partial and multipart responses, too.  We'll also support an open file
+cache (similar to nginx) which allows us to reuse open file descriptors.
+
+Under Linux, we'll support the splice(2) system call for zero-copy
+proxying {io_splice}[http://bogomips.org/ruby_io_splice/], too.