问题描述
Web Dynos 可以处理HTTP请求, Web Dynos 可以处理它们工人Dynos 可以处理作业。
但我不知道如何制作 Web Dynos 和工人Dynos 例如,我希望通过 Web Dynos
接收HTTP请求。能够相互沟通。
,发送给工人Dynos
,处理作业并将结果发送到 Web Dynos
,在Web上显示结果。
Node.js中有这种可能吗? (使用RabbitMQ或Kue等)?
我无法在表明,您的网络动态链接将需要通过中间机制(通常是一个队列)与您的工作人员dynos进行通信。
要完成听起来像你希望遵循的一般方法: 就实际的实现而言,我并不太熟悉Node.js中最好的库,但是粘贴这个过程的组件一起在Heroku上以提供。 队列:AMQP是一个支持良好的队列协议和插件可以充当您的网络和工作人员dynos之间的消息队列。 沙红色状态:您可以使用其中一个加载项来共享正在处理的作业状态或更高性能的内容如或。因此,总而言之,您必须使用中间附加组件在Heroku上的dynos之间进行通信。虽然这种方法需要更多的工程,但结果是一个正确解耦和可扩展的架构。 Web Dynos can handle HTTP Requests and while Web Dynos handles them Worker Dynos can handle jobs from it. But I don't know how to make Web Dynos and Worker Dynos to communicate each other. For example, I want to receive a HTTP request by Web Dynos , send it to Worker Dynos , process the job and send back result to Web Dynos , show results on Web. Is this possible in Node.js? (With RabbitMQ or Kue or etc)? I could not find an example in Heroku Documentation Or Should I implement all codes in Web Dynos and scaling Web Dynos only? 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: As far as actual implementation goes I'm not too familiar with the best libraries in Node.js, but the components that glue this process together are available on Heroku as add-ons. Queue: AMQP is a well-supported queue protocol and the CloudAMQP add-on can serve as the message queue between your web and worker dynos. Shared state: You can use one of the Postgres add-ons to share the state of an job being processed or something more performant such as Memcache or Redis. So, to summarize, you must use an intermediate add-on component to communicate between dynos on Heroku. While this approach involves a little more engineering, the result is a properly-decoupled and scalable architecture. 这篇关于如何在Heroku上使用Node.js与Web和Worker dynos进行通信?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
/ li>