bullmq vs bull vs agenda vs bee-queue vs kue
Node.js 任务队列库
bullmqbullagendabee-queuekue类似的npm包:
Node.js 任务队列库

任务队列库用于处理异步任务,允许开发者将任务放入队列中,并在后台处理这些任务。这些库通常用于处理需要延迟执行或需要高并发处理的任务,如发送电子邮件、处理图像或执行定时任务。它们提供了可靠的任务管理和调度机制,确保任务的顺序和成功执行。

npm下载趋势
3 年
GitHub Stars 排名
统计详情
npm包名称
下载量
Stars
大小
Issues
发布时间
License
bullmq2,139,1488,0052.27 MB3054 天前MIT
bull1,119,92216,183309 kB1481 年前MIT
agenda136,7119,585353 kB356-MIT
bee-queue36,4813,994106 kB362 年前MIT
kue18,8859,458-2889 年前MIT
功能对比: bullmq vs bull vs agenda vs bee-queue vs kue

存储后端

  • bullmq:

    BullMQ 也基于 Redis,提供更高级的功能和更好的性能,适合需要复杂任务管理的应用。

  • bull:

    Bull 同样使用 Redis 作为存储后端,支持复杂的任务处理和调度,适合需要高并发和高可靠性的场景。

  • agenda:

    Agenda 使用 MongoDB 作为存储后端,适合需要持久化和查询功能的应用。它可以存储任务的状态和调度信息,便于管理和监控。

  • bee-queue:

    Bee-Queue 使用 Redis 作为存储后端,提供高性能的任务队列,适合处理大量短任务。它的设计简单,易于使用。

  • kue:

    Kue 使用 Redis 作为存储后端,提供简单的 API 和用户界面,适合需要快速实现任务队列的场景。

任务调度

  • bullmq:

    BullMQ 提供更高级的任务调度功能,支持工作流和事件驱动的任务处理,适合需要复杂调度的应用。

  • bull:

    Bull 提供丰富的任务调度功能,包括延迟任务、优先级和重试机制,适合复杂的任务处理需求。

  • agenda:

    Agenda 提供简单的任务调度功能,支持定时任务和周期性任务,适合需要定期执行的任务场景。

  • bee-queue:

    Bee-Queue 主要用于处理即时任务,不支持定时调度,适合需要快速处理的任务。

  • kue:

    Kue 提供基本的任务调度功能,支持优先级和失败重试,适合简单的任务处理场景。

监控与管理

  • bullmq:

    BullMQ 提供更高级的监控和管理功能,支持工作流监控,适合复杂应用的需求。

  • bull:

    Bull 提供强大的监控和管理工具,可以实时查看任务状态,适合需要高可视化的应用。

  • agenda:

    Agenda 提供基本的监控功能,但缺乏图形化界面,适合开发者使用。

  • bee-queue:

    Bee-Queue 提供简单的监控功能,适合快速开发和调试。

  • kue:

    Kue 提供直观的用户界面,可以实时监控任务状态,适合需要可视化管理的场景。

学习曲线

  • bullmq:

    BullMQ 的学习曲线相对较陡,功能复杂,适合需要高级功能的开发者。

  • bull:

    Bull 的学习曲线稍陡,功能丰富,适合有一定经验的开发者。

  • agenda:

    Agenda 的学习曲线较平缓,API 简单易懂,适合初学者使用。

  • bee-queue:

    Bee-Queue 的学习曲线也较平缓,设计简单,易于上手。

  • kue:

    Kue 的学习曲线较平缓,API 简单,适合快速实现任务队列的场景。

性能

  • bullmq:

    BullMQ 性能更强,适合需要更高吞吐量的应用。

  • bull:

    Bull 性能优越,支持高并发任务处理,适合复杂应用。

  • agenda:

    Agenda 的性能依赖于 MongoDB 的性能,适合中小型应用。

  • bee-queue:

    Bee-Queue 具有极高的性能,适合处理大量短任务。

  • kue:

    Kue 性能良好,适合中小型应用的任务处理。

如何选择: bullmq vs bull vs agenda vs bee-queue vs kue
  • bullmq:

    选择 BullMQ 如果你需要 Bull 的增强版,支持更高级的功能,如工作流和事件驱动的任务处理,适合需要更复杂的任务管理和调度的应用。

  • bull:

    选择 Bull 如果你需要一个功能丰富的任务队列,支持优先级、延迟和重试机制,适合复杂的任务处理场景,并且希望有良好的监控和管理工具。

  • agenda:

    选择 Agenda 如果你需要一个基于 MongoDB 的轻量级任务调度器,适合定时任务和周期性任务的管理,并且希望使用简单的 API 来处理任务调度。

  • bee-queue:

    选择 Bee-Queue 如果你需要一个快速且简单的任务队列,适合处理大量的短任务,并且希望利用 Redis 的高性能特性。

  • kue:

    选择 Kue 如果你需要一个简单易用的任务队列,支持优先级和失败重试,并且希望有一个直观的用户界面来监控任务状态。

bullmq的README



The fastest, most reliable, Redis-based distributed queue for Node.
Carefully written for rock solid stability and atomicity.

Read the documentation

Follow @manast for *important* Bull/BullMQ/BullMQ-Pro news and updates!

🛠 Tutorials

You can find tutorials and news in this blog: https://blog.taskforce.sh/

News 🚀

🌐 Language agnostic BullMQ

Do you need to work with BullMQ on platforms other than Node.js? If so, check out the BullMQ Proxy

Official FrontEnd

Taskforce.sh, Inc

Supercharge your queues with a professional front end:

  • Get a complete overview of all your queues.
  • Inspect jobs, search, retry, or promote delayed jobs.
  • Metrics and statistics.
  • and many more features.

Sign up at Taskforce.sh

🚀 Sponsors 🚀

Dragonfly Dragonfly is a new Redis™ drop-in replacement that is fully compatible with BullMQ and brings some important advantages over Redis™ such as massive better performance by utilizing all CPU cores available and faster and more memory efficient data structures. Read more here on how to use it with BullMQ.

Used by

Some notable organizations using BullMQ:

Microsoft Vendure Datawrapper Nest Langfuse
Curri Novu NoCodeDB Infisical

The gist

Install:

$ yarn add bullmq

Add jobs to the queue:

import { Queue } from 'bullmq';

const queue = new Queue('Paint');

queue.add('cars', { color: 'blue' });

Process the jobs in your workers:

import { Worker } from 'bullmq';

const worker = new Worker('Paint', async job => {
  if (job.name === 'cars') {
    await paintCar(job.data.color);
  }
});

Listen to jobs for completion:

import { QueueEvents } from 'bullmq';

const queueEvents = new QueueEvents('Paint');

queueEvents.on('completed', ({ jobId }) => {
  console.log('done painting');
});

queueEvents.on(
  'failed',
  ({ jobId, failedReason }: { jobId: string; failedReason: string }) => {
    console.error('error painting', failedReason);
  },
);

Adds jobs with parent-child relationship:

import { FlowProducer } from 'bullmq';

const flow = new FlowProducer();

const originalTree = await flow.add({
  name: 'root-job',
  queueName: 'topQueueName',
  data: {},
  children: [
    {
      name: 'child-job',
      data: { idx: 0, foo: 'bar' },
      queueName: 'childrenQueueName',
      children: [
        {
          name: 'grandchild-job',
          data: { idx: 1, foo: 'bah' },
          queueName: 'grandChildrenQueueName'
        },
        {
          name: 'grandchild-job',
          data: { idx: 2, foo: 'baz' },
          queueName: 'grandChildrenQueueName'
        },
      ],
    },
    {
      name: 'child-job',
      data: { idx: 3, foo: 'foo' },
      queueName: 'childrenQueueName'
    },
  ],
});

This is just scratching the surface, check all the features and more in the official documentation

Feature Comparison

Since there are a few job queue solutions, here is a table comparing them:

FeatureBullMQ-ProBullMQBullKueBeeAgenda
Backendredisredisredisredisredismongo
Observables
Group Rate Limit
Group Support
Batches Support
Parent/Child Dependencies
Deduplication (Debouncing)
Deduplication (Throttling)
Priorities
Concurrency
Delayed jobs
Global events
Rate Limiter
Pause/Resume
Sandboxed worker
Repeatable jobs
Atomic ops
Persistence
UI
Optimized forJobs / MessagesJobs / MessagesJobs / MessagesJobsMessagesJobs

Contributing

Fork the repo, make some changes, submit a pull-request! Here is the contributing doc that has more details.

Thanks

Thanks for all the contributors that made this library possible, also a special mention to Leon van Kammen that kindly donated his npm bullmq repo.