Meteor 中的后台任务 [英] Background tasks in Meteor

查看:27
本文介绍了Meteor 中的后台任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道,有没有办法实现后台任务,也许是工作人员池.你能告诉我方向吗,我正在考虑为此编写包?

I'm wondering, is there is way to implement background taks, maybe with workers pool. Can you show me direction, i'm thinking about writing package for this?

推荐答案

2019更新

在考虑为任何东西编写包之前,首先看看是否有现有的包可以满足您的需求.在 Meteor 世界中,这意味着在 Atmosphere 上查找作业/队列/任务/工人管理/调度"包,然后在 npm 上查找相同的搜索词.您还需要更准确地定义您的需求:

2019 update

Before thinking about writing a package for anything, first look if there are existing packages that do what you need. In the Meteor world, this means looking on Atmosphere for "job/queue/task/worker management/scheduling" packages, then on npm for the same search terms. You also need to define your requirements more precisely:

  • 您想要持久性,还是内存中的解决方案可行?
  • 您是否希望能够将作业分配到不同的机器上?
  • job-collection - 可靠(我在 2014 年在生产中使用它启动),但目前处于维护模式.让您安排持久作业在任何地方(服务器、客户端)运行.
  • SteveJobs - 由 Max Savin 积极维护,他是多个 强大的流星工具
  • littledata:synced-cron - "用于 Meteor 的简单 cron 系统.它支持在多个进程之间同步作业."
  • job-collection - reliable (I used it in 2014 in production at a startup), but currently in maintenance mode. Lets you schedule persistent jobs to be run anywhere (servers, clients).
  • SteveJobs - actively maintained by Max Savin, the author of several powerful Meteor tools
  • littledata:synced-cron - "A simple cron system for Meteor. It supports syncronizing jobs between multiple processes."

废弃的包裹:

  • artwells:queue - priorities, scheduling, logging, re-queuing. Queue backed by MongoDB. Last code commit: 2015-Oct.
  • super basic cron packages: easycron. Last update: Dec 2015.
  • differential:workers - Spawn headless worker meteor processes to work on async jobs. Last code commit: Jan 2015
  • cron (since 2015)
  • PowerQueue - abandoned since 2014. Queue async tasks, throttle resource usage, retry failed. Supports sub queues. No scheduling. No tests, but nifty demo. Not suitable for running for a long while due to using recursive calls.

Meteor 已经可以直接使用 npm 包好几年了,所以这个问题相当于找 NPM 上的作业/工人/队列管理包.如果你不在乎持久性:

Meteor has been able to use npm packages directly for several years now, so this question amounts to finding job/worker/queue management packages on NPM. If you don't care about persistence:

  • Async提供了大约 70 个函数,其中包括通常的功能性"嫌疑人(mapreducefiltereach...)以及异步控制流的一些常用模式(parallel系列瀑布...)"
  • d3-queue - 极简主义,由 D3 作者 Mike Bostock 编写
  • Async "provides around 70 functions that include the usual 'functional' suspects (map, reduce, filter, each...) as well as some common patterns for asynchronous control flow (parallel, series, waterfall...)"
  • d3-queue - minimalistic, written by D3 author Mike Bostock

如果您确实需要持久性,因为 Meteor 已经使用了 MongoDB,使用具有持久性的作业调度包可能对 MongoDb 有利.最强大最流行的好像是Agenda,可惜几个月没维护了,它有大量的问题.

If you do want persistence, since Meteor uses MongoDB already, it may be advantageous to use a job scheduling package with persistence to MongoDb. The most powerful and popular seems to be Agenda, but unfortunately it hasn't been maintained in months, and it has a significant backlog of issues.

如果您愿意向您的项目添加由 redis 支持的依赖项,还有更多选择:

If you're willing to add a dependency backed by redis to your project, there are more choices:

  • bull - 适用于 Node 的功能最齐全的作业队列解决方案,由Redis支持
  • bee - 简单、快速、稳健.不会遭受Bull 展示的内存泄漏
  • Kue - Node 的优先作业队列
  • bull - the most full-featured job queue solution for Node, backed by Redis
  • bee - simple, fast, robust. Does not suffer from a memory leak that Bull exhibits
  • Kue - priority job queue for Node

和 MongoDB 一样,Redis 也可以提供高可用性(通过 Redis Sentinel),如果你想在多台工作机器之间分配作业,你可以将它们都指向同一个Redis服务器.

Like MongoDB, Redis can also provide high-availability (via Redis Sentinel), and if you want to distribute jobs among multiple worker machines, you can point them all at the same Redis server.

这篇关于Meteor 中的后台任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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