Nightmare! - an nginx alternative for unicorn

Eric Wong normalperson at yhbt.net
Sat Sep 3 06:52:27 EDT 2011


This is a slow client buffering layer which may be used instead
of nginx to protect Unicorn from slow clients.

Nightmare! will _never_ beat nginx in raw throughput nor
performance.  It /may/ be easier to setup than nginx and a
suitable alternative to Rainbows! for users who do not wish to
maintain a thread-safe/async-safe Rack application.

Code changes to the existing Unicorn codebase are minimal and
unlikely to impact existing users.  Nightmare! will never be
enabled by default.

Nightmare! supports streaming responses (new in Rails 3.1, but
ancient to Rack) with "lazy buffering" of upstream responses.
It'll stream as much of the response as possible immediately and
then buffer any data that can't.

Userspace memory buffering is kept to a minimum; if it can't fit
into generously-sized skbs (at least on modern Linux), it'll
be buffered to the _filesystem_ (which may be tmpfs or a real FS
with dirty ratios cranked up).

HTTPS support is planned/wired.  Somebody with SSL/crypto
knowledge needs to review
{kgio-monkey}[http://bogomips.org/kgio-monkey/] before it can be
trusted.  V nz n zbaxrl!  Qb abg gehfg zl pbqr!

Since Nightmare! already uses sendfile to serve buffers, a
"try_files" directive will be added to bypass Rack for simple
static file serving.  It will not serve directory indices nor
gzip, Rack already supports those.

Nightmare! internals are still in flux, and likely to remain so.
Like Unicorn internals, do not consider Nightmare itself a
stable development API unless explicitly told otherwise.

****** Use Rack for application logic ******

Nightmare! should work on Ruby 1.8.x and 1.9.x.

Configuration directives are not implemented, yet.   Eventually
it will support operation in standalone mode (so Nightmare! can
talk to Unicorn on different machines).

Extra RubyGems required (in addition to what Unicorn requires):

* kcar - client-side HTTP parser based on the Unicorn one
* sendfile - for sendfile() support
* kgio-monkey - (upcoming, optional) for HTTPS support


I've pushed this up to the "nightmare" branch of
git://bogomips.org/unicorn.git || http://bogomips.org/unicorn.git

Please review the code/tests if you have a chance, thanks for reading!

-- 
Eric Wong


More information about the mongrel-unicorn mailing list