Thin vs Unicorn on Heroku

Thin is easy to configure – not optimal, but it just works in the Heroku environment.

Unicorn can be more efficient, but it needs to be configured: How many workers? Preload App? What do you pick?

I have released Unicorn Heroku apps with workers set to 3, 5 and 8 – just based on how big each app is – how much code, how much memory is used and how much traffic you get all go into picking this number, and you need to monitor over time to make sure you got the number right, and your app isn’t running out of memory.

Preload false – this will make your app start slower, but when Unicorn restarts a worker, this is ‘safer’ with network connections (memcache, postgres, mongo etc)

Preload true – this is better, but you need to handle server re-connections correctly in the pre and post fork code.

Thin has none of these issues out of the box, but you only get process of execution.

Summary: It’s really hard to configure Unicorn out of the box to work well (or at all) for everyone, whereas Thin can just work to get people running with fewer support requests.

Leave a Comment