Notes:
Unicorn is an HTTP server for Rack applications designed to only serve
fast clients on low-latency, high-bandwidth connections and take
advantage of features in Unix/Unix-like kernels. Slow clients should
only be served by placing a reverse proxy capable of fully buffering
both the the request and response in between Unicorn and slow clients.
* http://unicorn.bogomips.org/
* mongrel-unicorn@rubyforge.org
* git://git.bogomips.org/unicorn.git
Changes:
Thanks to Augusto Becciu for finding a bug in the HTTP parser
that caused a TypeError (and 500) when a rare client set the
"Version:" header which conflicts with the HTTP_VERSION header
we parse in the first line of the request[1].
Horizontal tabs are now allowed as leading whitespace in header
values as according to RFC 2616 as pointed out by
Iñaki Baz Castillo[2].
Taking a hint from Rack 1.1, the "logger" configuration
parameter no longer requires a "close" method. This means some
more Logger replacements may be used.
There's a new, optional, Unicorn (and maybe Passenger)-only
middleware, Unicorn::OobGC[2] that runs GC outside of the normal
request/response cycle to help out memory-hungry applications.
Thanks to Luke Melia for being brave enough to test and report
back on my big_app_gc.rb monkey patch[3] which lead up to this.
Rails 3 (beta) support:
Using "unicorn" is still recommended as Rails 3 comes with
a config.ru, but "unicorn_rails" is cleaned up a bit and
*should* work as well as "unicorn" out-of-the-box. Feedback
is much appreciated.
Rubinius updates:
USR2 binary upgrades are broken due to
{TCPServer,UNIXServer}.for_fd[5][6] being broken
(differently).
Repeatedly hitting the server with signals in a tight
loop is unusual and not recommended[7].
There are some workarounds and general code cleanups for other
issues[8], as well but things should generally work unless you
need USR2 upgrades. Feedback and reports would be greatly
appreciated as usual.
MRI support:
All tests (except old Rails) run and pass under 1.9.2-preview3.
1.8.7 and 1.9.1 work well as usual and will continue to be
supported indefinitely.
Lets hope this is the last release before 1.0. Please report
any issues on the mailing list[9] or email us privately[a].
Don't send HTML mail.
[1] - http://mid.gmane.org/AANLkTimuGgcwNAMcVZdViFWdF-UcW_RGyZAue7phUXps@mail.gmail.com
[2] - http://mid.gmane.org/i2xcc1f582e1005070651u294bd83oc73d1e0adf72373a@mail.gmail.com
[3] - http://unicorn.bogomips.org/Unicorn/OobGC.html
[4] - http://unicorn.bogomips.org/examples/big_app_gc.rb
[5] - http://github.com/evanphx/rubinius/issues/354
[6] - http://github.com/evanphx/rubinius/issues/355
[7] - http://github.com/evanphx/rubinius/issues/356
[8] - http://github.com/evanphx/rubinius/issues/347
[9] - mailto:mongrel-unicorn@rubyforge.org
[a] - mailto:unicorn@bogomips.org
Changes:
.document | 1 +
.gitignore | 4 +-
Documentation/unicorn.1.txt | 2 +-
FAQ | 5 +-
GIT-VERSION-GEN | 2 +-
GNUmakefile | 51 +++++++++++--
KNOWN_ISSUES | 27 +------
PHILOSOPHY | 5 +-
Rakefile | 25 ++++++-
Sandbox | 78 ++++++++++++++++++++
bin/unicorn_rails | 50 ++++---------
examples/big_app_gc.rb | 33 ++++++++
examples/unicorn.conf.minimal.rb | 13 +++
examples/unicorn.conf.rb | 12 ++-
ext/unicorn_http/unicorn_http.rl | 16 ++++-
ext/unicorn_http/unicorn_http_common.rl | 2 +-
lib/unicorn.rb | 16 +---
lib/unicorn/configurator.rb | 30 ++++++--
lib/unicorn/const.rb | 4 +-
lib/unicorn/oob_gc.rb | 58 +++++++++++++++
lib/unicorn/util.rb | 16 ++--
local.mk.sample | 68 ++++++++---------
t/GNUmakefile | 9 ++-
t/rails3-app/.gitignore | 4 +
t/rails3-app/Gemfile | 26 +++++++
t/rails3-app/Rakefile | 10 +++
.../app/controllers/application_controller.rb | 5 +-
t/rails3-app/app/helpers/application_helper.rb | 2 +
.../app/views/layouts/application.html.erb | 14 ++++
t/rails3-app/config.ru | 4 +
t/rails3-app/config/application.rb | 46 ++++++++++++
t/rails3-app/config/boot.rb | 6 ++
t/rails3-app/config/database.yml | 22 ++++++
t/rails3-app/config/environment.rb | 5 +
t/rails3-app/config/environments/development.rb | 19 +++++
t/rails3-app/config/environments/production.rb | 42 +++++++++++
t/rails3-app/config/environments/test.rb | 32 ++++++++
.../config/initializers/backtrace_silencers.rb | 7 ++
t/rails3-app/config/initializers/inflections.rb | 10 +++
t/rails3-app/config/initializers/mime_types.rb | 5 +
t/rails3-app/config/initializers/secret_token.rb | 7 ++
t/rails3-app/config/initializers/session_store.rb | 8 ++
t/rails3-app/config/locales/en.yml | 5 +
t/rails3-app/config/routes.rb | 58 +++++++++++++++
t/rails3-app/db/seeds.rb | 7 ++
t/rails3-app/doc/README_FOR_APP | 2 +
.../.gitignore => t/rails3-app/lib/tasks/.gitkeep | 0
.../app-2.3.5 => t/rails3-app}/public/404.html | 0
.../app-2.3.5 => t/rails3-app}/public/500.html | 0
.../rails/app-2.3.5 => t/rails3-app}/public/x.txt | 0
t/rails3-app/script/rails | 9 ++
t/rails3-app/test/performance/browsing_test.rb | 9 ++
t/rails3-app/test/test_helper.rb | 13 +++
.../rails3-app/vendor/plugins/.gitkeep | 0
t/t0300-rails3-basic.sh | 56 ++++++++++++++
t/test-lib.sh | 3 +-
test/exec/test_exec.rb | 23 +++++-
test/rails/{app-2.3.5 => app-2.3.8}/.gitignore | 0
test/rails/{app-2.3.5 => app-2.3.8}/Rakefile | 0
.../app/controllers/application_controller.rb | 0
.../app/controllers/foo_controller.rb | 0
.../app/helpers/application_helper.rb | 0
test/rails/{app-2.3.5 => app-2.3.8}/config/boot.rb | 0
.../{app-2.3.5 => app-2.3.8}/config/database.yml | 0
.../{app-2.3.5 => app-2.3.8}/config/environment.rb | 0
.../config/environments/development.rb | 0
.../config/environments/production.rb | 0
.../{app-2.3.5 => app-2.3.8}/config/routes.rb | 0
test/rails/{app-2.3.5 => app-2.3.8}/db/.gitignore | 0
test/rails/{app-2.3.5 => app-2.3.8}/log/.gitignore | 0
.../rails/{app-2.3.5 => app-2.3.8}/public/404.html | 0
.../rails/{app-2.3.5 => app-2.3.8}/public/500.html | 0
test/rails/{app-2.3.5 => app-2.3.8}/public/x.txt | 0
test/rails/test_rails.rb | 4 +
test/unit/test_http_parser.rb | 12 +++-
test/unit/test_http_parser_ng.rb | 22 +++++-
test/unit/test_signals.rb | 4 +-
test/unit/test_socket_helper.rb | 8 +-
test/unit/test_util.rb | 40 ++++++-----
unicorn.gemspec | 2 +
80 files changed, 896 insertions(+), 182 deletions(-)
commit 6c1e66a3f3e9b15305f965f52fd8c35fbd8f8d5b
Author: Eric Wong
Date: Tue Jun 8 08:50:37 2010 +0000
unicorn 0.990.0 - inching towards 1.0
Thanks to Augusto Becciu for finding a bug in the HTTP parser
that caused a TypeError (and 500) when a rare client set the
"Version:" header which conflicts with the HTTP_VERSION header
we parse in the first line of the request[1].
Horizontal tabs are now allowed as leading whitespace in header
values as according to RFC 2616 as pointed out by
Iñaki Baz Castillo[2].
Taking a hint from Rack 1.1, the "logger" configuration
parameter no longer requires a "close" method. This means some
more Logger replacements may be used.
There's a new, optional, Unicorn (and maybe Passenger)-only
middleware, Unicorn::OobGC[2] that runs GC outside of the normal
request/response cycle to help out memory-hungry applications.
Thanks to Luke Melia for being brave enough to test and report
back on my big_app_gc.rb monkey patch[3] which lead up to this.
Rails 3 (beta) support:
Using "unicorn" is still recommended as Rails 3 comes with
a config.ru, but "unicorn_rails" is cleaned up a bit and
*should* work as well as "unicorn" out-of-the-box. Feedback
is much appreciated.
Rubinius updates:
USR2 binary upgrades are broken due to
{TCPServer,UNIXServer}.for_fd[5][6] being broken
(differently).
Repeatedly hitting the server with signals in a tight
loop is unusual and not recommended[7].
There are some workarounds and general code cleanups for other
issues[8], as well but things should generally work unless you
need USR2 upgrades. Feedback and reports would be greatly
appreciated as usual.
MRI support:
All tests (except old Rails) run and pass under 1.9.2-preview3.
1.8.7 and 1.9.1 work well as usual and will continue to be
supported indefinitely.
Lets hope this is the last release before 1.0. Please report
any issues on the mailing list[9] or email us privately[a].
Don't send HTML mail.
[1] - http://mid.gmane.org/AANLkTimuGgcwNAMcVZdViFWdF-UcW_RGyZAue7phUXps@mail.gmail.com
[2] - http://mid.gmane.org/i2xcc1f582e1005070651u294bd83oc73d1e0adf72373a@mail.gmail.com
[3] - http://unicorn.bogomips.org/Unicorn/OobGC.html
[4] - http://unicorn.bogomips.org/examples/big_app_gc.rb
[5] - http://github.com/evanphx/rubinius/issues/354
[6] - http://github.com/evanphx/rubinius/issues/355
[7] - http://github.com/evanphx/rubinius/issues/356
[8] - http://github.com/evanphx/rubinius/issues/347
[9] - mailto:mongrel-unicorn@rubyforge.org
[a] - mailto:unicorn@bogomips.org
commit 524f57bc1d5334a50bff0340e8b1c541fa6536e4
Author: Eric Wong
Date: Tue Jun 8 08:29:04 2010 +0000
cleanup makefiles, restore aggregation screwup
The publish_doc target belongs in main, since other people
may update the website.
local.mk.sample enables a subset of tests for Rubinius
and allows them to run in parallel with the MRI tests.
And it was NOT a UUoC after all, there are multiple files to
aggregate :x
commit 9afe763e3b33cf344908c5831c26f3f925acf368
Author: Eric Wong
Date: Tue Jun 8 07:57:00 2010 +0000
GNUmakefile: add test-all and test-integration targets
Long overdue
commit 8b7b52c08ad5a4822c3ea1550c9fccd838696db2
Author: Eric Wong
Date: Tue Jun 8 07:03:35 2010 +0000
test: mark failing tests for Rubinius
They cannot be worked around, but tickets have been filed
upstream (I still hate all bug trackers besides Debian's).
TCPServer.for_fd (needed for zero-downtime upgrades):
http://github.com/evanphx/rubinius/issues/354
UnixServer.for_fd (needed for zero-downtime upgrades):
http://github.com/evanphx/rubinius/issues/355
Signal handling behavior seems broken (OOM or segfaults):
http://github.com/evanphx/rubinius/issues/356
commit 2760d1e0d459a8e92eadf78cdf9f09d6a3109003
Author: Eric Wong
Date: Tue Jun 8 07:00:08 2010 +0000
update test infrastructure to run Rubinius tests
In parallel with other of Rubies, of course. We need to rely on
RUBY_ENGINE since RUBY_VERSION is 1.8.7 and that conflicts with
the most popular MRI version.
Since Rubinius doesn't support some command-line options, we
still need to rely on MRI for a few things. Also fixing an
embarrassing UUoC in the process.
commit 9110e76b36e224434aaa853625844f3b1ad69ae1
Author: Eric Wong
Date: Tue Jun 8 06:49:44 2010 +0000
reopen_logs: no need to preserve encoding args
Since we accidentally dropped open_args a while back, nothing
seems to have broken :x So apparently MRI preserves it for us,
and test/unit/test_util.rb agrees.
commit b835a92623d716e8b1e9f174f24d3a543416e3e7
Author: Eric Wong
Date: Tue Jun 8 06:43:29 2010 +0000
test_socket_helper: additional test for path equality
This fails under Rubinius.
ref: http://github.com/evanphx/rubinius/issues/355
commit c7739a2259798859ddb2827fd6f90366813e5212
Author: Eric Wong
Date: Tue Jun 8 06:41:36 2010 +0000
reopen_logs: avoid modifying ObjectSpace while iterating
Creating File objects while iterating ObjectSpace for File
objects may hit subtle bugs. It may only be safe in MRI, and
even then it's not behavior that sounds sane to rely on. So
stop doing it.
commit 765ff628e11775a9b684759d6c191b4934ff78fb
Author: Eric Wong
Date: Tue Jun 8 06:11:57 2010 +0000
spew backtrace when config reloading fails
It can be useful to track down problems with
commit b3cf35936337ff455f1b3ccb52b8bba1775efe9c
Author: Eric Wong
Date: Tue Jun 8 05:12:59 2010 +0000
test-exec: fix racyness in HUP test
I'm not sure what I was smoking when I originally (and
knowingly) wrote the racy code.
commit 364d2669e9f718813b0883b0d9f2428303af1dcd
Author: Eric Wong
Date: Tue Jun 8 05:11:16 2010 +0000
cleanup master_sleep loop
No need for extra checks when we're just doing read_nonblock.
We'll also avoid reallocating a 16K buffer every time we sleep,
we can just reuse the buffer the workers normally use to process
request.
commit e29ed24c56e7bc15b5f6a26cbfc40877b2fd5116
Author: Eric Wong
Date: Tue Jun 8 04:38:00 2010 +0000
test_http_parser: memory usage test for non-MRI
Non-MRI runtimes (like Rubinius) may implement garbage
collection very differently than MRI.
commit f09f5bc32b54e9d2e9f594fd2a2358af0a0f999a
Author: Eric Wong
Date: Tue Jun 8 03:26:43 2010 +0000
workaround IO#reopen bug in rbx when reopening logs
IO#reopen in Rubinius seems to munge the O_APPEND flag when passed a
path, however passing an actual IO object. However, at the system call
level, everything is the same.
ref: http://github.com/evanphx/rubinius/issues/347
commit 9a028876d23c7aab1420d81d3c001fbc91354538
Author: Eric Wong
Date: Tue Jun 8 02:46:08 2010 +0000
http: move Version: header check into a less common path
Since the "Version" header is uncommon and never hits our
optimized case, we don't need to check for it in the common
case.
commit 7d2295fa774d1c98dfbde2b09d93d58712253d24
Author: Augusto Becciu
Date: Mon Jun 7 23:02:43 2010 -0300
http: ignore Version: header if explicitly set by client
When Unicorn receives a request with a "Version" header, the
HttpParser transforms it into "HTTP_VERSION". After that tries to add
it to the request hash which already contains a "HTTP_VERSION" key
with the actual http version of the request. So it tries to append the
new value separated by a comma. But since the http version is a
freezed constant, the TypeError exception is raised.
According to the HTTP RFC
(http://www.w3.org/Protocols/rfc2616/rfc2616-sec7.html#sec7.1) a
"Version" header is valid. However, it's not supported in rack, since
rack has a HTTP_VERSION env variable for the http version. So I think
the easiest way to deal with this problem is to just ignore the header
since it is extremely unusual. We were getting it from a crappy bot.
ref: http://mid.gmane.org/AANLkTimuGgcwNAMcVZdViFWdF-UcW_RGyZAue7phUXps@mail.gmail.com
Acked-by: Eric Wong
commit ed9cc7ba22bab5b3f7262d869a8bc03f14b2d4cb
Author: Eric Wong
Date: Sat Jun 5 03:26:51 2010 +0000
File.readable? and File.writable? are more readable
...than "test ?r" and "test ?w"
Not everybody comes from a Unix shell programming background,
even though they *should* ;)
commit 798ea473865e6d4a4ed2a35987ba40d2fcbfaf6f
Author: Eric Wong
Date: Fri Jun 4 13:49:09 2010 -0700
configurator: logger: drop "close" requirement
Rack::Lint in Rack 1.1.0 does not require a "close" method for
env["rack.logger"], and we never explicitly close our logger,
either. This more easily allows the use of alternative
Logger-like implementations such as SyslogLogger.
commit 2d5a4b075801493a85c6e8d2dbdf0c95002e046d
Author: Eric Wong
Date: Fri Jun 4 13:42:34 2010 -0700
doc: emphasize the importance of stderr_path
While second nature to myself, stderr_path may be an
overlooked configuration parameter for some users. Also,
add a minimal sample configuration file that is shorter
and hopefully less intimidating to new users.
commit 59a625b1732915891baba8fc82d47798bbabad13
Author: Eric Wong
Date: Thu Jun 3 23:51:34 2010 +0000
tests: disable Rails 2.x tests under Ruby 1.9.2
They are not compatible, and the Rails 3 tests will
be completely separate.
commit b9745c5b53e2690c5fd0b1355b429c62a658f27c
Author: Eric Wong
Date: Thu Jun 3 23:16:31 2010 +0000
gemspec: add development dependency on isolate
commit 8e78b8a815c2fafcf9428c30a0961932132d790f
Author: Eric Wong
Date: Thu Jun 3 23:14:23 2010 +0000
test: rails 3: automatically run isolate if needed
should be safe enough...
commit 45266fe79c8928931d032b3c20044938bb0f1104
Author: Eric Wong
Date: Thu Jun 3 23:11:11 2010 +0000
test: http_parser_ng: fix broken assertion
This was noticed by running under Ruby 1.9.2-preview3
commit e687ede9cd390b09bf1e87c6de18924ec57ff3c3
Author: Eric Wong
Date: Thu Jun 3 23:01:20 2010 +0000
tests: add preliminary Rails 3 tests
We'll be switching to Isolate and shell-based tests
since the old test/unit-based Rails test was basically
a shell script written in Ruby.
commit 8e55e561a1bcba57bf429c9c2111ec5351fcb1b3
Author: Eric Wong
Date: Thu Jun 3 22:53:28 2010 +0000
move Rails 2.3.x test to Rails 2.3.8
This allows us to gets rid of the Rack 1.0.1 dependency when
running Rails tests since previous versions of Rails 2.3.x
needed Rack 1.0.1, where as Rails 2.2.x and below could be used
with any version of Rack (under Unicorn only).
commit 4b44e21957e4cb8ec6ace5604fbe096dfd8959d2
Author: Eric Wong
Date: Thu Jun 3 22:52:11 2010 +0000
unicorn_rails: avoid duplicating config.ru logic
This should allow "unicorn_rails" to be used seamlessly
with Rails 3 projects which package config.ru for you.
commit 536f9019a8300011d4ae99994fb0c99882719c3b
Author: Eric Wong
Date: Tue May 18 15:06:19 2010 -0700
doc: PHILOSOPHY: update Rainbows! section
commit e78e07e0726993f7e1146518643a2b5e6eb27baa
Author: Eric Wong
Date: Tue May 18 14:14:43 2010 -0700
doc: Sandbox: updates for Isolate 2.x
Isolate 2.0.0 appears to have quietly released, so update
the docs for it. Fix capitalization while we're at it, too.
commit ced5c2f959f2560e904c9b82837b1a2f645b8621
Author: Eric Wong
Date: Tue May 18 14:11:12 2010 -0700
doc: unicorn.1: the command name is "unicorn"
commit 95b75a5043b34f39ece4f52befb4b3f884dfdd20
Author: Eric Wong
Date: Fri May 14 18:27:35 2010 +0000
add Unicorn::OobGC middleware
This middleware allows configurable out-of-band garbage
collection outside of the normal request/response cycle.
It offers configurable paths (to only GC on expensive actions)
and intervals to limit GC frequency.
It is only expected to work well with Unicorn, as it would
hurt performance on single-threaded servers if they
have keepalive enabled. Obviously this does not work well
for multi-threaded or evented servers that serve multiple
clients at once.
commit bbefb358174e73d7edbf8a1014817fe1557e39af
Author: Eric Wong
Date: Fri May 7 15:00:16 2010 -0700
doc: KNOWN_ISSUES: add Sandbox page link
commit f636f7c31acd6d84bdc058a921e969608ae4b19e
Author: Eric Wong
Date: Fri May 7 12:03:06 2010 -0700
doc: add Sandbox document for bundler/isolate users
This may be expanded to cover other similar tools, as well,
including tools that don't use RubyGems.
commit 935912a422cabfd323f9b4ff268ded09a2ebe7a6
Author: Eric Wong
Date: Fri May 7 18:20:49 2010 +0000
http: allow horizontal tab as leading whitespace in header values
This is allowed by RFC 2616, section 2.2, where spaces and
horizontal tabs are counted as linear white space and linear
white space (not just regular spaces) may prefix field-values
(section 4.2).
This has _not_ been a real issue in ~4 years of using this
parser (starting with Mongrel) with clients in the wild.
Thanks to Iñaki Baz Castillo for pointing this out.
commit 3c6fceea7bca1932081113c516da7a94b94fe9c6
Author: Eric Wong
Date: Thu May 6 14:14:57 2010 -0700
doc: kill Dir.chdir example
Modern version of Unicorn have working_directory available and
should use that instead.
commit 510a48dafc5f7e2cb618d785885395c79570821c
Author: Eric Wong
Date: Thu May 6 14:08:51 2010 -0700
examples: add big_app_gc monkey patch
|