response: allow normal Hash for crafting Range headers
[rainbows.git] / FAQ
blobf45568bbab195f7224013eb39a7fb0c8cb2fdd6c
1 = Frequently Asked Questions about \Rainbows!
3 === Why is \Rainbows! a separate project from Unicorn?
5 \Rainbows! is for the odd, corner-case requests that Unicorn is poorly
6 suited for.  More scalable concurrency models introduce additional
7 complexity that Unicorn users and developers are uncomfortable with for
8 the common cases.
11 === What complexity?  Threads/events/actors are easy to work with!
13 Good for you.  Some of us depend on libraries incompatible with those
14 models, or are just too lazy to deal with them for the majority of
15 requests we service.
18 === Isn't "rainbows" a branch of Unicorn?
20 That functionality is now in the Revactor model of \Rainbows!
23 === What happened to the "gossamer" branch of Unicorn?
25 It became the ThreadPool model of \Rainbows!
28 === Which concurrency model should I use?
30 It depends on your application, libraries, Ruby stack and use cases.
31 That's why we support as many concurrency model as we can.  Each model
32 has their own strengths and weaknesses in terms of maturity,
33 ease-of-debugging, compatibility, performance, and memory usage.
36 === Should I put \Rainbows! behind nginx to serve slow clients?
38 It is optional.  You can still use nginx to route certain requests to
39 Unicorn and others to \Rainbows!  nginx will always outperform
40 \Rainbows! in both pure reverse proxy applications and for serving
41 static files,  but \Rainbows! is for hosting applications that are more
42 easily-implemented in Ruby than C.
45 === Should I use \Rainbows! to serve static files?
47 It depends on the size and amount of static files you're serving.  If
48 you're serving a lot of static files (especially large ones), then by
49 all means use nginx.  If not, then \Rainbows! is likely a "good enough"
50 solution even if nginx will always outperform it in raw throughput.
53 === How do I support SSL?
55 If you need streaming "rack.input" to do on-the-fly upload processing
56 within your Rack application, then using an SSL proxy such as
57 {Pound}[http://www.apsis.ch/pound/] or {Stunnel}[http://stunnel.org/] is
58 required.  Pound has built-in X-Forwarded-For support while Stunnel
59 requires a extra {patch}[http://haproxy.1wt.eu/download/patches/].
61 If you don't need streaming "rack.input", then nginx is a great HTTPS
62 reverse proxy.
64 Refer to the {Unicorn FAQ}[http://unicorn.bogomips.org/FAQ.html] on how
65 to ensure redirects go to "https://" URLs.
68 === Is there a "rainbows_rails" command like there is "unicorn_rails"?
70 No.
72 "unicorn_rails" was written primarily to support older versions of
73 Rails.  Since \Rainbows! is designed for newer applications based on
74 Rack, it can just use a "config.ru" file like other Rack frameworks and
75 applications.
77 For Rails 3.x, you should already have a config.ru file and
78 "rainbows(1)" will work out-of-the-box like "rackup(1)".  Rails 3
79 will support RACK_ENV as set by "rainbows(1)", so you won't need
80 to set RAILS_ENV.
82 For Rails 2.3.x, the following config.ru will work for you:
84   ENV["RAILS_ENV"] ||= ENV["RACK_ENV"]
85   require "#{::File.expand_path('config/environment')}"
86   use Rails::Rack::Static
87   run ActionController::Dispatcher.new
89 For older versions of Rails, the following config.ru will work:
91   ENV["RAILS_ENV"] ||= ENV["RACK_ENV"]
92   require "#{::File.expand_path('config/boot')}"
93   require "#{::File.expand_path('config/environment')}"
94   require 'unicorn/app/old_rails'
95   require 'unicorn/app/old_rails/static' # not needed with Unicorn 0.95+
96   use Unicorn::App::OldRails::Static
97   run Unicorn::App::OldRails.new
99 One thing to watch out for is that RAILS_ENV will not be set in the
100 environment for you, thus we set it to match RACK_ENV.
102 === I'm using threads and Rails is misbehaving!
104 If you use any of the threaded concurrency models, you will need to use
105 {config.threadsafe!}[http://m.onkey.org/thread-safety-for-your-rails]
106 in your config/environments/$RAILS_ENV.rb