Thin vs Unicorn on Heroku

前端 未结 3 622
既然无缘
既然无缘 2020-12-08 07:21

Just wanted to get people\'s opinions on using Unicorn vs Thin as a rails server. Most of the articles/benchmarks I found online seem very incomplete, so it would nice to ha

3条回答
  •  半阙折子戏
    2020-12-08 07:36

    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.

提交回复
热议问题