为什么每个节点运行许多网络服务器实例?

发布于 2025-01-02 21:14:10 字数 326 浏览 3 评论 0原文

我经常看到(Rails | Java | PHP | Node.js | nginx | 等等)的设置,其中每个服务器运行着许多 Web 服务器软件实例(nginx、apache、mongrel,没关系)。 并为同一个应用程序提供服务,而不是单个“巨大”实例。

为什么会选择这样的方法呢?我不清楚为什么为同一应用程序提供服务的许多较小实例可能比调整为使用最大可用内存和线程的一个实例更好。

为了让自己清楚起见,我经常看到诸如“...我们有 10 台服务器,每台运行 20 个<某些网络服务器>实例”之类的说法。为什么不是“10 个服务器,每个运行 1 个<某些网络服务器>实例”?

I often see setups of (Rails | Java | PHP | Node.js | nginx | etc..) where there are many instances of the webserver software (nginx, apache, mongrel, it doesn't matter) running per server and serving the same application, instead of a single, "huge" instance.

Why would one choose such approach? It is not clear for me why many smaller instances serving the same application could be better than one instance tuned to use the max available ram and threads.

To make myself clear, I often see statements like "... we have 10 servers, running 20 instances of <some webserver> each". Why not "10 server, running 1 instance of <some webserver> each"?

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

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

发布评论

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

评论(2

好久不见√ 2025-01-09 21:14:10

仅当 Web 服务器是单线程(如 Node.js 或 Mongrel)以利用多个 CPU 核心时,运行 Web 服务器的多个实例才有意义。

Running multiple instances of a webserver only makes sense if it is single-threaded (like node.js or mongrel) to take advantage of multiple CPU cores.

不交电费瞎发啥光 2025-01-09 21:14:10

我想对 Steve 的精彩回复进行补充,即基于事件的多线程服务器结合了能够在每个线程处理多个请求的优势,同时能够使用系统的所有可用 CPU 核心。

除了 CPU 核心之外,使用一个程序实例而不是多个程序实例可以节省内存(重复的代码和数据)和 CPU 缓存,避免不断的垃圾。

I would add to the excellent reply of Steve that an event-based multi-threaded servers combines the benefits of being able to process many requests per thread - while at the same time beeing able to use all the available CPU Cores of a system.

Besides CPU Cores, having one single program instance instead of many is saving memory (duplicated code and data) and CPU Caches from constant trashing.

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