简体   繁体   English

Heroku最佳实践时钟与node.js

[英]Heroku best practice clocks with node.js

I'm wondering what the best way is to setup a clock process on Heroku. 我想知道在Heroku上设置时钟进程的最佳方法是什么。 My app is built entirely in Node and I was planning on using node-schedule to specify my schedules. 我的应用程序完全由Node构建,我计划使用node-schedule来指定我的日程安排。

My question is: should the clock process itself trigger the events in my cron process and run them within it's own allocated dyno? 我的问题是:时钟进程本身是否应该触发我的cron进程中的事件并在它自己分配的dyno中运行它们? Heroku seems to indicate that you should use a worker to handle this. Heroku似乎表明你应该使用一个工人来处理这个问题。 In that case, I'm wondering how I can get my clock process to tell the worker to run a specific procedure? 在那种情况下,我想知道如何让我的时钟进程告诉工人运行特定的程序?

I've been reading up on the Python method to do this and it seems like they are simply triggering the process within the same dyno. 我一直在阅读Python方法来执行此操作,看起来它们只是在同一个dyno中触发进程。

Thanks. 谢谢。

Heroku says clock processes should trigger a new dyno, which makes sense for scalability since you could turn your frequency up to 11 and break the clock process. Heroku说时钟进程应该触发一个新的dyno,这对于可伸缩性是有意义的,因为你可以将频率提高到11并打破时钟进程。 https://devcenter.heroku.com/articles/scheduled-jobs-custom-clock-processes https://devcenter.heroku.com/articles/scheduled-jobs-custom-clock-processes

I would use https://github.com/toots/node-heroku to kick off new processes in separate one-time dynos. 我会使用https://github.com/toots/node-heroku在单独的一次性dynos中启动新进程。 But, if you want to have a pool of workers that process clock processes, than you'll need a queue like Resque or Kue. 但是,如果你想拥有一个处理时钟进程的工作池,那么你需要一个像Resque或Kue这样的队列。 The clock process will enqueue new tasks and the worker process(es) will dequeue them. 时钟进程将排队新任务,工作进程将使它们出列。

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

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