47

I recently 'upgraded' my app to the cedar platform on Heroku. By default, I am using thin as a web server. But I have always been tempted to use unicorn for concurrency and having my dyno dollar go father. But I worry there are some gotchas in using something other than Thin.

Does anyone have real-life experience with this decision?


Notes:

I want to know reasons why everyone shouldn't do this

Mukyuu
  • 6,436
  • 8
  • 40
  • 59
Jonathan
  • 16,077
  • 12
  • 67
  • 106

4 Answers4

28

Update -- 3 months later.

I have been using unicorn in production for 3 months, and I have been very pleased. I use 4 unicorn workers per dyno.

One thing you do need to keep an eye out for is memory consumption and leakage. In effect instead of having 512MB of memory per dyno -- you have that divided by the number of heroku workers. But keeping that in mind -- it has been a great cost saver

Jonathan
  • 16,077
  • 12
  • 67
  • 106
  • Thanks for sharing... I am evaluating the same move and even did some [benchamarking for my app](http://ylan.segal-family.com/blog/2012/08/20/better-performance-on-heroku-thins-vs-unicorn-vs-puma/). It definitely looks like unicorn will result in some cost saving. – Ylan S Aug 21 '12 at 23:14
  • To enhance the value of your answer, include instructions or links to instructions for using Unicorn. Cuz I'm thinking that's what I'll do! – slothbear Dec 17 '12 at 04:19
  • 1
    Do you know if there is any issue with using global variables (for example does each worker keep it's own global variables, or are they sharing/clobbering the same global scope)? This isn't a common pattern in MVC but we do use it in some places. Thanks! – Brian Armstrong Jan 13 '13 at 04:43
7

No reason not to do it - I use Unicorn on Heroku with much success.

John Beynon
  • 37,398
  • 8
  • 88
  • 97
6

Heroku has just written a post about using Unicorn : https://blog.heroku.com/archives/2013/2/27/unicorn_rails

I'll try it now, it seems like it's the way to go, both for performance and cost saving.

Emmanuel
  • 254
  • 3
  • 11
0

If you use Thin, and your code doesn't clear requests very quickly, then you're in trouble - since Heroku uses random routing, requests will stack up on a blocked dyno even if there are free dynos. Using Unicorn seems better, if you can handle the memory hit, because it's less likely that all of your forks will get slow requests at the same time. It doesn't solve Heroku's random-routing problem, but it should help a lot.

Links and explanations in this answer:

https://stackoverflow.com/a/19965981/1233555

Community
  • 1
  • 1
ChrisPhoenix
  • 1,040
  • 1
  • 11
  • 16