简体   繁体   English

在Heroku中使用集群模块运行Node.js App毫无意义吗?

[英]Running Node.js App with cluster module is meaningless in Heroku?

Heroku can run Heroku可以运行

Web Dynos 网络测功机

and

Worker Dynos 工人发电机

so that Web Dynos take care of routes 这样Web Dynos可以处理路由

and worker Worker Dynos take care of processing works. 工人Dynos负责加工工作。

Since there is a unit of Dyno , 由于存在一个Dyno单位,

It seems using Node.js cluster module is meaningless to me on Heroku. 在Heroku上,使用Node.js集群模块似乎对我毫无意义。

Because Node.js cluster module is to use all cores of server CPU 因为Node.js群集模块将使用服务器CPU的所有核心

and Dyno seems virtual unit of CPU core to me. Dyno在我看来似乎是CPU核心的虚拟单元。

Am I right? 我对吗? Or is it still worth to run a node.js app with cluster module? 还是值得通过集群模块运行node.js应用程序?

I've found that it actually worth to use cluster module 我发现实际上值得使用集群模块

because each dyno has 4 CPU cores. 因为每个dyno都有4个CPU内核。


Reference: http://www.quora.com/Heroku/How-powerful-is-one-Heroku-dyno 参考: http : //www.quora.com/Heroku/How-powerful-is-one-Heroku-dyno

This is an old question, thought I should update to a more complete answer. 这是一个老问题,我应该更新为更完整的答案。

According to this table on their documentation 根据此表上的文档

  • 1X Dynos have 1 cluster 1X Dynos有1个群集
  • 2X Dynos have 2 clusters 2X Dynos有2个群集
  • PX Dynos have 12 clusters PX Dynos具有12个群集

So, assuming that you are using 1X dynos, it won't be necessary to implement clusters. 因此,假设您使用的是1X dynos,则无需实现群集。 If you are using the other ones, it is a good idea to do so. 如果您正在使用其他服务器,则最好这样做。

The number of clusters can be found on the WEB_CONCURRENCY environment variable. 可以在WEB_CONCURRENCY环境变量中找到集群的数量。

That's very good news to me, i assumed that a dyno is just one core. 对我来说这是个好消息,我认为测功机只是一个核心。 I actually wrote and open sourced a small but very nicely made cluster setup (backed by redis and job queue) 我实际上编写并开源了一个小型但制作精良的集群设置(由redis和作业队列支持)

https://bitbucket.org/jeveloper/nodejscluster https://bitbucket.org/jeveloper/nodejscluster

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM