nginx 和 Thin 的区别

发布于 2024-09-18 01:03:51 字数 176 浏览 4 评论 0原文

这是一个关于rails环境中的nginx和thin的新手问题。在阅读/学习 Rails 时,我经常听说 nginx 和 Thin 是 Rails 站点的绝佳组合。在阅读每个的描述时,它们都将自己描述为网络服务器,所以我对这个组合带来的结果有点困惑。如果有人可以简要描述它们是什么以及它们如何相互补充,我将不胜感激。

谢谢!

This is a newbie question around nginx and thin in the rails environment. In reading/learning on rails I frequently hear about nginx and thin being a great combination for a rails site. In reading the descriptions of each, they both describe themselves as web servers, so I'm a little confused at what the combination brings to the table. If anyone could briefly describe what they are and how they complement each other I would be greatly appreciative.

Thanks!

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

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

发布评论

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

评论(3

盛装女皇 2024-09-25 01:03:51

典型的小型应用程序部署将在一台计算机上运行 Nginx(或 Apache)和少量 Thin(或 Mongrel、Unicorn 等)服务器。

Nginx 接收每个请求。然后它直接提供静态文件(css、js、图像、缓存的东西)。如果请求需要处理,则将请求交给 Rails 进程(Thin)。

这样,您的(相对)较慢的应用程序服务器就可以从提供静态文件中解放出来,并且您的 Web 服务器可以提供某种负载平衡。

Nginx/Thin 相对于 Apache/Mongrel 之类的东西的好处是 Nginx/Thin 可以直接通过 unix 套接字进行通信,从而消除了通过 tcp/ip 堆栈进行通信的开销。

A typical small application deployment will have Nginx(or Apache) and a handful of Thin(or Mongrel, Unicorn, etc) servers running all on one machine.

Nginx receives every request. It then serves and static files directly (css, js, images, cached stuff). If the request requires processing it then hands the request off to a rails process (Thin).

This way your (relatively) slow application servers are freed up from serving static files, and your web server is providing a sort of load balancing.

The benefit of Nginx/Thin over something like Apache/Mongrel is that Nginx/Thin can communicate directly via a unix socket, removing the overhead of communicating via the tcp/ip stack.

半步萧音过轻尘 2024-09-25 01:03:51

Thin是一个应用程序服务器,而Nginx是一个Web服务器。

来自 http://www.javaworld.com/javaqa/ 2002-08/01-qa-0823-appvswebserver.html

应用程序服务器通过各种协议(可能包括 HTTP)向客户端应用程序公开业务逻辑。 Web 服务器主要处理发送 HTML 以在 Web 浏览器中显示,而应用程序服务器提供对供客户端应用程序使用的业务逻辑。应用程序可以使用此逻辑,就像调用对象的方法(或过程世界中的函数)一样。

Thin is an application server while Nginx is a web server.

From http://www.javaworld.com/javaqa/2002-08/01-qa-0823-appvswebserver.html

The application server exposes business logic to client applications through various protocols, possibly including HTTP. While a Web server mainly deals with sending HTML for display in a Web browser, an application server provides access to business logic for use by client application programs. The application program can use this logic just as it would call a method on an object (or a function in the procedural world).

讽刺将军 2024-09-25 01:03:51

出于无知(我从未使用过 Thin),将 nginx 和应用程序服务器混合在一起是很正常的,使用 nginx 提供静态内容并充当应用程序服务器的反向代理。

这使得很容易将极快的静态内容服务与所选的应用程序服务器(不同的编程语言有所不同)混合在一起,所有这些都来自相同的地址:端口。

Speaking out of ignorance (I've never used Thin), it is quite normal to mix nginx and an application server together, using nginx to serve up static content and act as a reverse proxy for the application server.

This makes it easy to blend ludicrously fast static content serving with the application server of choice (which varies between programming languages), all coming from the same address:port.

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