什么是生产部署节点到AWS目前的最佳实践 [英] What is the current best practice for a production deployment of node to AWS

查看:105
本文介绍了什么是生产部署节点到AWS目前的最佳实践的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我评估nodejs我们的web应用程序的小部分,它似乎将是一个不错的选择。我知道节点是年轻,移动速度快,但现在看来似乎终于得到了投入生产类别。然而,谷歌搜索左右,大部分的信息,我看到生产部署一岁,仍然发出警告脆弱的节点,怎么能和可以将错误出意外,其次是一些解决方案,以重新启动。这不吓唬我自动消失,但似乎缺乏正确的方式官字放点在那里可靠。​​

I'm evaluating nodejs for small portion of our web application where it seems like it would be a good fit. I know that node is young and moving fast, but it seems like it has finally gotten to the "ready for production category". However, googling around, most information I see on production deployments are a year old and still warn about how fragile node can be and can error out unexpectedly, followed by some solutions to restart. This doesn't scare me away by itself, but there seems to be lack of official word on "the right way" to put node out there reliably.

推荐答案

的群集似乎是一个不错的选择,虽然根据您的操作系统可能有较差的负载均衡性能。一个非常简单的版本是这样的:

cluster seems to be a good option, although depending on your OS it might have poor load-balancing performance. A very simple version would be something like this:

var cluster = require('cluster')

if(cluster.isMaster) {
  var i, worker, workers;
  for(i = 0;i < numWorkers;i++) {
    worker = cluster.fork();
    workers[worker.process.pid] = worker;
  }
  cluster.on("exit", function(deadWorker) {
    delete workers[deadWorker.process.pid];
    worker = cluster.fork();
    workers[worker.process.pid] = worker;
  });
}
else {
  //be a real server process
}

这是一个不错的选择,因为这两个给你一些稳定性重启死的过程,并为您提供共享负载的多个进程。需要注意的是的群集基本修改server.listen使职工都监听事件从主,这是做听力的到来。这是这里的自由负载均衡来自

This is a nice option because it both gives you some stability by restarting dead processes, and gives you multiple processes that share the load. Note that cluster basically modifies server.listen so that workers are all listening to events coming from the master, which is doing the listening. This is where the "free" load-balancing comes from.

Cluster文档可以在这里找到: http://nodejs.org/api/cluster.html

Cluster documentation can be found here: http://nodejs.org/api/cluster.html

这也可能是值得的,如果你希望能够触发某些事件,比如杀死并重新启动所有的进程,或杀死所有进程,关闭主进程处理两个信号。

It may also be worth having the master process handle a couple of signals if you want to be able to trigger certain events, such as killing and restarting all the processes, or killing all the processes and shutting down.

这篇关于什么是生产部署节点到AWS目前的最佳实践的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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