Webrick 作为生产服务器与 Thin 还是 Unicorn? [英] Webrick as production server vs. Thin or Unicorn?
问题描述
似乎理所当然地认为您不能将 Webrick 用作生产服务器,但我真的找不到任何提及原因的地方.共识似乎是:Webrick 适合开发,但 Thin 或 Unicorn 是生产的选择,时期."
It seems like it's taken for granted that you must not use Webrick as production server, but I can't really find anywhere mentioning why. The consensus seems to be: "Webrick is ok for development, but Thin or Unicorn is the choice for production, period."
我确实查看了瘦服务器的主页,它谈到了请求/秒,但由于没有注释,因此我不太了解图表.
I did look up Thin server's homepage and it talks about requests/second but I don't really understand the graph since there's no annotation.
谁能告诉我为什么与 Webrick 相比我应该使用 Thin 或 Unicorn?使用 Webrick 进行开发有什么好处吗?我一直在使用 Webrick,因为它带有 Rails,我认为它是默认的应该是有原因的.
Can anyone let me know why I should use Thin or Unicorn compared to Webrick? Also is there any benefit to using Webrick for development? I've been using Webrick since it comes with rails, and I think there should be a reason why it's default.
顺便说一下,我正在使用 Heroku.
I'm using Heroku by the way.
推荐答案
几个重要的原因
- 它是用 Ruby 编写的(参见 http://github.com/ruby/ruby/tree/trunk/lib/webrick)
- 编辑它没有生产网站通常需要的许多功能,例如多个工作人员(特别是预分叉、生命周期管理、异步处理等)、重定向、重写、等
- it's written in Ruby (see http://github.com/ruby/ruby/tree/trunk/lib/webrick)
- Edited it doesn't have many features that a production website usually needs, like multiple workers (in particular, pre-forking, life cycle management, asynchronous handling, etc), redirects, rewriting, etc
当我提到重定向/重写时,我指的是使用 Webrick,您必须在不同层(Rack、Sinatra、Rails、自定义 Webrick 代码等)处理重写.这需要您启动额外的 ruby处理程序"来执行您的重写代码.对于低流量站点,这可能没问题,因为您可能已经预热了进程,什么都不做.但是,对于流量较高的站点,对于前端服务器(Apache、Nginx 等)无需启动 Ruby* 即可处理的某些内容而言,这是服务器上的额外负载,而且速度可能快几个数量级.
When I mention redirects/rewrites, I'm referring to the fact that using Webrick, you have to handle rewrites at a different layer (Rack, Sinatra, Rails, custom Webrick code, etc). This requires you to spin up extra ruby "handlers" to perform your rewrite code. For a low traffic site, this may be fine as you may have pre-warmed processes doing nothing already. However, for a higher traffic site, this is extra load on the server for something that the front end servers (Apache, Nginx, etc) can handle without spinning up Ruby*, and probably orders of magnitude faster.
* 例如,如果您在负载均衡器后面运行,您可以将所有重写流量路由到没有安装 ruby 的服务器,并让您的主服务器只管理主要流量.这种重写流量可能是由于 SEO 的站点更改或类似的原因.另一种情况是具有多个组件的站点,可能一个部分是 Rails,另一个部分是 PHP,并且两者都需要重写(即重写旧的 PHP 路径到 Rails)
这篇关于Webrick 作为生产服务器与 Thin 还是 Unicorn?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!