如何在 Heroku 上与 Node.js 通信 Web 和 Worker dynos? [英] How to communicate Web and Worker dynos with Node.js on Heroku?

查看:20
本文介绍了如何在 Heroku 上与 Node.js 通信 Web 和 Worker dynos?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Web Dynos 可以处理 HTTP 请求

Web Dynos can handle HTTP Requests

Web Dynos 处理它们时,Worker Dynos 可以通过它处理作业.

and while Web Dynos handles them Worker Dynos can handle jobs from it.

但我不知道如何让 Web DynosWorker Dynos 相互通信.

But I don't know how to make Web Dynos and Worker Dynos to communicate each other.

例如,我想通过 Web Dynos

,发送给Worker Dynos

,处理作业并将结果发送回Web Dynos

, process the job and send back result to Web Dynos

,在网络上显示结果.

这在 Node.js 中可行吗?(使用 RabbitMQ 或 Kue 等)?

Is this possible in Node.js? (With RabbitMQ or Kue or etc)?

我在 Heroku 文档

还是我应该在 Web Dynos 中实现所有代码并仅缩放 Web Dynos?

Or Should I implement all codes in Web Dynos and scaling Web Dynos only?

推荐答案

作为关于后台工作的高级文章和排队表明,您的 Web dynos 需要通过中间机制(通常是队列)与您的工作 dynos 进行通信.

As the high-level article on background jobs and queuing suggests, your web dynos will need to communicate with your worker dynos via an intermediate mechanism (often a queue).

要完成听起来您希望做的事情,请遵循以下一般方法:

To accomplish what it sounds like you're hoping to do follow this general approach:

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