似乎理所当然地认为您不能将 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.
推荐答案几个重要的原因
当我提到重定向/重写时,我指的是使用 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?
发布评论