不同核心上的node.js的多个实例 [英] Multiple instances of node.js on different cores

查看:152
本文介绍了不同核心上的node.js的多个实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想设置4个不同的node.js实例,每个实例都在自己的核心上。 node.js是否在同一个核心上堆叠新实例,或者也将它们设置在新核心上?

I would like to set up 4 different node.js instances, each on their own core. Does node.js stack new instances on the same core, or set them on new cores also?

实例不相关并单独接收请求。我希望cpu负载均匀分布。
我一直无法找到这个问题的明确答案。

The instances are unrelated and receive requests individually. I would like the cpu load spread out evenly. I haven't been able to find a definitive answer to this question.

推荐答案

一般情况下系统会尝试这样做,最大限度地利用cpu。但是,如果要定位特定CPU,则应查看 TaskSet 。它设置了该过程的亲和力。

In general the system will try to do it this own, to maximize utilization of cpu. However if you want to target a particular CPU, you should check out TaskSet. It set's the affinity of the process.

此外,还有几个有用的问题可以讨论相同的主题。看看。

Also there are several useful questions that discuss the same topic. Have a look.


  1. Upstart :不同核心Nodej上的每个进程

节点.js - 定位cpu核心<​​/a>

Node.js - targeting a cpu core

Node多核机器上的.js

In AmazonEC2 cpu核心和nodejs

如何部署云中的Node.js使用多核来实现高可用性

利用cpu的多节点模块

还有一个模块,群集,对CPU利用率也非常有用。它允许您分叉多个进程以将负载分配到多个核心。

There is also a module, Cluster, that can also be very useful for CPU utilization. It let's you fork multiple processes to distribute load to multiple cores.

更新

最后,我根据OP部署了类似的东西。

Finally, I have deployed something similar according to OP.

案例1。


  1. 我有一个拥有8个cpu内核的专用服务器。

  2. 我已经部署了一个单节点线程并使用了Cluster模块来共享工作负载(如pl47ypus PS:感谢他的回答。)

  3. 结果很好,但有时儿童线程可能会变得没有响应,所以我决定尝试使用我在之前的应用程序中使用的旧过程。

  1. I have a dedicated sever with 8 cores of cpu.
  2. I have deployed a single node thread and used the Cluster module to share the work load (As Described by pl47ypus PS: thanks for his answer ).
  3. The result is good, but some times the child thread may become unresponsive, So I have decided to try the old process, which I had used in my previous application.






案例2。


  1. 相同的服务器,我已经部署了8个具有不同端口的node.js进程。

  2. 然后我将nginx放入前面这些,用工作流程8监听端口80.

  3. 结果优于案例1,也很容易配置nginx,也是最稳定的。

我还建议您尝试一些上述解决方案,并在每种情况下继续监控您的系统;像CPU,内存使用和io。最后,从您的测试中,您将看到针对您的用例的最佳解决方案。每个应用程序都有自己的要求,因此最好尝试找到您的应用程序真正需要的内容。

I also suggest you just try some of the solutions mentioned and keep monitoring your system in each case; like CPU, memory usage and io. Finally, from your tests you will see the best solution for your use case. Every application has its own requirements, so its better to try and find what your applications real need.

这篇关于不同核心上的node.js的多个实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆