Skip to content

Instantly share code, notes, and snippets.

@FooBarWidget
Created February 20, 2014 08:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FooBarWidget/9109559 to your computer and use it in GitHub Desktop.
Save FooBarWidget/9109559 to your computer and use it in GitHub Desktop.
Unicorn edge cases

One example is that, by default, Unicorn requires 2x memory usage during a rolling restart. If you have 6 Unicorn worker processes, then during a rolling restart Unicorn will spawn another 6, and then replace the original 6 only after the new 6 have all been spawned. It is possible to perform rolling restart processes one-by-one (which requires dramatically less memory usage) but you have to write all sorts of configuration and scripts to do that.

As for the edge cases: what happens if something fails during a rolling restart? For example if there is a temporary network problem to the database server, causing a process to fail to spawn. Unicorn will not handle it properly, and will continue to kill off the old processes even though no new ones can be spawned, causing downtime.

Phusion Passenger Enterprise's rolling restart solves these issues nicely and elegantly. It does not require 2x memory usage, it does not require large scripts and configuration files, it does the right thing out of the box. It handles edge cases properly: if a process fails to start, it aborts the rolling restart, keeps the processes that you already had up until then, and notifies the administrator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment