不同 Ruby on Rails 生产 Web 服务器之间的建议(和差异)

发布于 2024-08-11 01:54:25 字数 463 浏览 4 评论 0原文

很快,我计划将我的第一个 Ruby on Rails 应用程序部署到生产环境,我什至选择了一个 Web 主机,它具有您期望从 RoR 提供商那里获得的所有托管服务器和 Capistrano 优点。

该提供商允许 Mongrel、Thin、Passenger 和FastCGI Web 服务器,看起来非常灵活,但老实说我不知道​​它们之间的区别。我对他们进行了一些研究,但是当他们开始谈论功能和最大同时请求数时,一切都变得有点过分了——而且这些数据似乎根据发布者的不同而有所不同。

我看过 Passenger(表面上)——这对我来说确实很有吸引力——但我的印象是 Passenger 并不是真正的网络服务器,而更像是 Apache 或 nginx 之上的一层并托管生成应用程序的实例(如 Mongrel 集群)。

任何人都可以请我用外行术语来解释这些差异,以便我可以做出明智的选择(因为任何看过《印第安纳琼斯和最后的十字军东征》的人都知道如果你选择不当会发生什么)。

Very soon I plan on deploying my first Ruby on Rails application to a production environment and I've even picked a webhost with all the managed server and Capistrano goodness you'd expect from a RoR provider.

The provider allows for Mongrel, Thin, Passenger & FastCGI web servers, which seems very flexible, but I honestly don't know the differences between them. I have looked into them some, but it all gets a bit much when they start talking about features and maximum simultaneous requests - and that this data seems to vary depending on who's publishing it.

I have looked at Passenger (on the surface) - which does seem very appealing to me - but I was under the impression that Passenger wasn't the actual webserver, and instead was more like a layer on top of Apache or nginx and managed spawned instances of the application (like a Mongrel cluster).

Can anyone please set me straight with the differences in layman's terms so as I can choose wisely (because anyone who's seen Indiana Jones and the Last Crusade knows what happens if you choose poorly).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

掩饰不了的爱 2024-08-18 01:54:25

简短回答

使用 Apache/Nginx + Passenger。 Passenger 快速、可靠、易于配置和部署。 Passenger 已被大量大型 Rails 应用程序采用,包括 Shopify

替代文本
(来源:modrails.com

长答案

忘记 CGI 和 FastCGI。一开始没有其他选择,因此运行 Rails 的唯一方法是使用 CGI 或更快的浏览器 FastCGI。现在几乎没有人在 CGI 下运行 Rails。最新的 Rails 版本不再提供 .cgi 和 .fcgi 运行程序。

Mongrel 已成为广泛采用的解决方案,是 CGI 和 FCGI 的最佳替代品。许多站点仍然使用 Mongrel 和 Mongrel 集群,但是 Mongrel 项目几乎已经死亡,许多项目已经转移到其他解决方案(主要是 Passenger)。
此外,基于 Mongrel 的架构非常难以配置,因为它需要前端代理(thin、ngnix)和由多个 Mongrel 实例组成的后端架构。

《乘客》自发布以来就受到广泛关注。许多项目出于多种原因从 Mongrel 转向 Passenger,包括(但不限于)易于部署、可维护性和性能。此外,Passenger 现在可用于 Apache 和 Ngnix。

使用 Passenger 最简单的方式是 Apache + Passenger 配置。一个 Apache 安装和多个 Passenger 进程。

如果需要更好的性能和可扩展性,可以使用 Ngnix 作为前端代理,将所有 Rails 请求转发到多个后端服务器,每个后端服务器由 Apache + Passenger 组成。
我不会在这里讨论技术细节,该解决方案旨在供高流量的 Rails 项目使用。

更复杂的解决方案包括不同级别的组合,包括 http 代理和服务器。您可以通过阅读 GitHub 和 < 的一些内部详细信息了解我在说什么。 a href="http://heroku.com/how/architecture" rel="nofollow noreferrer">Heroku。

目前,Passenger 是大多数 Rails 项目的最佳答案。

Short answer

Go with Apache/Nginx + Passenger. Passenger is fast, reliable, easy to configure and deploy. Passenger has been adopted by a large number of big Rails applications, including Shopify.

alt text
(source: modrails.com)

The long answer

Forget about CGI and FastCGI. In the beginning there were no other alternatives so the only way to run Rails was using CGI or the faster browser FastCGI. Nowadays almost nobody runs Rails under CGI. The latest Rails versions no longer provides .cgi and .fcgi runners.

Mongrel has been a largely adopted solution, the best replacement for CGI and FCGI. Many sites still use Mongrel and Mongrel cluster, however Mongrel project is almost dead and many projects already moved to other solutions (mostly Passenger).
Also, a Mongrel based architecture is quite hard to configure because it needs a frontend proxy (thin, ngnix) and a backend architecture composed of multiple Mongrel instances.

Passenger has been gaining widespread attention since it was released. Many projects switched from Mongrel to Passenger for many reasons, including (but not limited to) easy deployment, maintainability and performance. Additionally, Passenger is now available for both Apache and Ngnix.

The simplest way to use Passenger is the Apache + Passenger configuration. One Apache installation and multiple Passenger processes.

If you need better performance and scalability, you can use Ngnix as a frontend proxy and forward all Rails requests to multiple backend servers, each one composed of Apache + Passenger.
I'm not going into the technical details here, this solution is intended to be used by Rails projects with an high level of traffic.

Even more complex solutions include a combination of different levels including http proxies and servers. You can have an idea of what I'm talking about reading some internal details from GitHub and Heroku.

Right now, Passenger is the best answer for most Rails projects.

眼眸 2024-08-18 01:54:25

Mongrel 和 Thin 是单个 ruby​​ 进程服务器,您可以在某种类型的代理(例如 Apache 或 Nginx)后面作为集群运行多个服务器。代理将管理 Mongrel 或 Thin 的哪个实例为请求提供服务。

Passenger 在 Apache 或 Nginx 之间创建一个接口,创建应用程序生成进程,然后分叉进程以在传入请求时为其提供服务。有很多配置选项可以设置这些进程的生存时间、可以有多少个进程以及他们在死之前会满足多少请求。这是迄今为止扩展和处理高流量应用程序的最常见方法,但它并非没有缺点。这只能在 *nix 操作系统(linux、mac os x 等)上完成。此外,这些进程按需启动,因此,如果一段时间内没有人访问您的站点,它们的进程就会终止,并且下一个请求会延迟重新启动。对于 Mongrel 和 Thin,该进程始终在运行。但有时,新的流程对于内存使用等来说可能是一件好事。

如果它将是一个流量相对较低的站点,Mongrel 或 Thin 提供了一种简单、易于管理的方式来部署应用程序。对于需要像 Passenger 这样的智能排队和流程管理的高流量站点,这是一个非常好的解决方案。

至于 fastcgi,您可能想将其用作最后一个选项。

Mongrel and Thin are single ruby process servers that you would run multiple of as a cluster behind some type of proxy (like Apache or Nginx). The proxy would manage which instance of Mongrel or Thin services the requests.

Passenger creates an interface between Apache or Nginx that creates an application spawning process and then forks out processes to server up incoming requests as they come in. There are a lot of configuration options for how long those processes live, how many there can be, and how many requests they will serve before they die. This is by far the most common way to scale up and handle a high traffic application, but it is not without drawbacks. This can only be done on a *nix operating system (linux, mac os x, etc). Also, these processes spin up on demand, so if no one accesses your site for a while, they processes die and the next request has the delay of it starting back up again. With Mongrel and Thin, the process is always running. Sometimes though, your processes being new and fresh can be a good thing for memory usage etc.

If it is going to be a relatively low traffic site, Mongrel or Thin provides a simple, easy to manage way to deploy the application. For higher traffic sites where you need the smart queuing and process management of something like Passenger, it is a very good solution.

As for fastcgi, you probably want to use that as a last option.

深府石板幽径 2024-08-18 01:54:25

我使用 Passenger + nginx。它的效果真的非常好。

I use Passenger + nginx. It works really, really well.

作死小能手 2024-08-18 01:54:25

为了让乘客立即夸耀性能,我建议使用 ruby​​ 企业版。

To get some instant performance boast with passenger, I recommend using ruby enterprise edition.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文