Skip to content

Instantly share code, notes, and snippets.

View FooBarWidget's full-sized avatar

Hongli Lai FooBarWidget

View GitHub Profile
@FooBarWidget
FooBarWidget / Unicorn edge cases.md
Created February 20, 2014 08:58
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 hand

@benoist
benoist / better_logger.rb
Created September 10, 2011 07:44 — forked from indirect/better_logger.rb
Rails 3 logs with severity and PIDs
# You must require this file in application.rb, above the Application
# definition, for this to work. For example:
#
# # PIDs prepended to logs
# if Rails.env.production?
# require File.expand_path('../../lib/pid_logger', __FILE__)
# end
#
# module MyApp
# class Application < Rails::Application