bullmq vs node-resque vs agenda vs bee-queue vs bull vs kue
Node.js における非同期ジョブキュー管理ライブラリ
bullmqnode-resqueagendabee-queuebullkue類似パッケージ:

Node.js における非同期ジョブキュー管理ライブラリ

agendabee-queuebullbullmqkuenode-resque はすべて Node.js で非同期ジョブやバックグラウンドタスクを管理するためのライブラリです。これらはジョブをキューに登録し、ワーカープロセスが非同期で処理することで、メール送信、ファイル変換、データ同期などの重い処理をメインアプリケーションから切り離すことを可能にします。各ライブラリはデータストア(MongoDB または Redis)や API 設計、再試行・遅延実行のサポート、保守状況において大きく異なり、アーキテクチャ選定の際に重要な判断材料となります。

npmのダウンロードトレンド

3 年

GitHub Starsランキング

統計詳細

パッケージ
ダウンロード数
Stars
サイズ
Issues
公開日時
ライセンス
bullmq3,829,7848,6442.34 MB3544日前MIT
node-resque13,8491,409708 kB202ヶ月前Apache-2.0
agenda09,651295 kB21ヶ月前MIT
bee-queue04,026107 kB454ヶ月前MIT
bull016,247309 kB1471年前MIT
kue09,467-2889年前MIT

Node.js ジョブキュー管理ライブラリ:Agenda、Bee-Queue、Bull、BullMQ、Kue、node-resque の徹底比較

Node.js アプリケーションで非同期処理やバックグラウンドジョブを扱う際、信頼性の高いジョブキュー管理ライブラリは不可欠です。本稿では、agendabee-queuebullbullmqkuenode-resque の6つの主要なnpmパッケージを、実際の開発現場での使用観点から技術的に比較します。各ライブラリの設計思想、Redis依存の有無、APIスタイル、再試行・遅延実行のサポート、そして保守状況に焦点を当て、プロフェッショナルなフロントエンド開発者がアーキテクチャ選定を行う際に役立つ情報を提供します。

📌 基本的な目的とデータストアの違い

これらのライブラリはすべて「ジョブ(タスク)をキューに登録し、ワーカーが非同期で処理する」という基本的なパターンを実現しますが、裏側で使用するデータストアが大きく異なります。この点がアーキテクチャ選定の最も重要な分岐点です。

MongoDB を使う agenda

agendaMongoDB 専用のジョブスケジューラです。MongoDB が既にシステムに導入済みで、追加のインフラ(Redisなど)を避けたい場合に最適です。

// agenda: MongoDB にジョブを保存
const Agenda = require('agenda');
const agenda = new Agenda({ db: { address: 'mongodb://localhost:27017/agenda' } });

agenda.define('send email', async (job) => {
  await sendEmail(job.attrs.data.to, job.attrs.data.subject);
});

await agenda.start();
agenda.now('send email', { to: 'user@example.com', subject: 'Hello' });

Redis を使う残りの5つ

bee-queuebullbullmqkuenode-resque はすべて Redis をデータストアとして使用します。Redis はメモリ上にデータを保持し、高速なキュー処理が可能ですが、永続化設定やクラスタリングなどの運用負荷が伴います。

// bee-queue: Redis を使用
const Queue = require('bee-queue');
const queue = new Queue('email', { redis: { host: 'localhost', port: 6379 } });

queue.process(async (job) => {
  return await sendEmail(job.data.to, job.data.subject);
});

queue.createJob({ to: 'user@example.com', subject: 'Hello' }).save();

💡 重要なポイント: MongoDB と Redis のどちらを使うかは、既存のインフラ、チームの運用経験、ジョブの重要度(失敗許容度)によって決まります。agenda 以外は Redis 必須です。

⚠️ 非推奨(Deprecated)ライブラリの確認

公式情報に基づき、以下のライブラリは 新規プロジェクトでの使用を避けるべきです。

  • kue: GitHub リポジトリおよび npm ページに明確な非推奨(deprecated)の記載があります。最後の更新は2018年であり、メンテナンスされていません。
  • node-resque: 公式 npm ページに「This package is deprecated. Please use @resque/resque instead.」と記載されています。ただし、@resque/resque は別パッケージのため、ここでは node-resque は非推奨と判断します。

結論: 新規プロジェクトでは kuenode-resque は使用しないでください。代わりに bullbullmqbee-queueagenda を検討しましょう。

🔁 再試行(Retry)と遅延実行(Delay)の実装スタイル

ジョブが失敗したときの再試行や、特定時間後に実行する遅延ジョブは、多くのアプリケーションで必要です。各ライブラリの実装方法を比較します。

agenda: スケジューリング機能内蔵

agenda は MongoDB の日付クエリを使って、自然な形で遅延と再試行を実現します。

// agenda: 失敗時に最大3回再試行、10分後に再実行
agenda.define('process payment', { retry: 3, retryDelay: 10 * 60 * 1000 }, async (job) => {
  // ...
});

// 5分後に実行
agenda.schedule('in 5 minutes', 'process payment', { orderId: 123 });

bee-queue: シンプルで軽量

bee-queue は再試行回数を指定できますが、遅延実行は直接サポートしていません(代替手段が必要)。

// bee-queue: 最大2回再試行
const queue = new Queue('task', { activateDelayedJobs: true });

queue.process({ concurrency: 5, retryLimit: 2 }, async (job) => {
  // ...
});

// 遅延実行は非サポート(workaround 必要)

bull / bullmq: 機能豊富で柔軟

bullbullmq は再試行、遅延、優先度、レート制限など、ほぼすべての高度な機能をサポートしています。

// bull: 再試行と遅延
const Queue = require('bull');
const queue = new Queue('video transcoding');

queue.process(async (job) => {
  // ...
});

// 遅延付きジョブ(5秒後)
queue.add({ videoId: 123 }, { delay: 5000 });

// 再試行設定(指数バックオフ)
queue.add({ videoId: 123 }, {
  attempts: 3,
  backoff: { type: 'exponential', delay: 1000 }
});
// bullmq: 同様の機能(APIがよりモダン)
import { Queue, Worker } from 'bullmq';

const queue = new Queue('audio');
const worker = new Worker('audio', async (job) => { /* ... */ });

await queue.add('transcode', { file: 'song.mp3' }, {
  delay: 5000,
  attempts: 3,
  backoff: { type: 'exponential', delay: 1000 }
});

💡 ポイント: 複雑なスケジューリングや再試行戦略が必要なら、bull または bullmq が最適です。bee-queue はシンプルさを重視するケース向けです。

🧩 API設計と使いやすさ

bull vs bullmq: 古典的 vs モダン

bull はコールバックとPromiseを混在させた古典的なAPIですが、bullmq は完全にPromise/async-await対応で、TypeScriptサポートも優れています。

// bull: クラシックなAPI
const queue = new Bull('tasks');
queue.process((job, done) => {
  // 処理後に done() を呼ぶ
  done(null, result);
});

// bullmq: モダンなasync/await
const worker = new Worker('tasks', async (job) => {
  return await process(job.data);
});

推奨: 新規プロジェクトでは bullmq を選ぶのが安全です。bull はまだ使われていますが、bullmq が公式に推奨される次世代版です。

bee-queue: 最小限のAPI

bee-queue は「キュー作成 → ジョブ登録 → 処理」の流れが非常にシンプルで、学習コストが低いです。

const queue = new Queue('simple');
queue.process(async (job) => { /* ... */ });
queue.createJob(data).save();

🛠️ UIダッシュボードと監視

運用中にジョブの状態を確認できるUIがあると便利です。

  • bull / bullmq: 公式の bull-board というUIツールがあり、簡単に統合できます。
  • agenda: サードパーティ製の agenda-ui がありますが、公式サポートではありません。
  • bee-queue: 公式UIなし。監視にはカスタムスクリプトが必要です。

📊 まとめ:選定ガイド

ライブラリデータストア非推奨特徴
agendaMongoDBMongoDBユーザー向け、スケジューリング内蔵
bee-queueRedis軽量・シンプル、高度機能少なめ
bullRedis機能豊富、UIあり、古めのAPI
bullmqRedisbull の次世代版、モダンAPI、TypeScript対応
kueRedis非推奨、新規プロジェクトで使用禁止
node-resqueRedis非推奨@resque/resque へ移行推奨

💡 最終的なアドバイス

  • MongoDB しか使いたくない?agenda を選ぶ。
  • 最小限の依存でシンプルなキューが欲しい?bee-queue を選ぶ。
  • 高度なスケジューリング、再試行、UI監視が必要?bullmq を選ぶ(bull はレガシー案件向け)。
  • kuenode-resque は絶対に新規で使わない — 公式で非推奨と明記されています。

これらのライブラリはどれも「ジョブをキューに入れて処理する」という同じゴールを持ちますが、裏側の設計思想と機能セットは大きく異なります。あなたのプロジェクトのインフラ、チームのスキル、将来の拡張性を考慮して、慎重に選んでください。

選び方: bullmq vs node-resque vs agenda vs bee-queue vs bull vs kue

  • bullmq:

    Redis を使い、最新の async/await 対応、TypeScript サポート、高度なジョブ管理機能(指数バックオフ、レート制限、UI統合)を求める新規プロジェクトに最適です。bull の公式後継として積極的に開発されています。

  • node-resque:

    非推奨のライブラリです。npm ページに「This package is deprecated. Please use @resque/resque instead.」と記載されています。新規プロジェクトでは使用せず、代替パッケージを検討する必要があります。

  • agenda:

    MongoDB を既に使用しており、追加のインフラ(Redisなど)を避けたい場合に最適です。スケジューリング機能が内蔵されており、日時指定のジョブ実行が自然に実装できます。ただし、Redis を使いたい場合は選択肢から外れます。

  • bee-queue:

    軽量でシンプルなAPIを求める場合に適しています。Redis を使用しますが、高度な機能(遅延実行、複雑な再試行戦略)はサポートしておらず、最小限の依存でジョブキューを実現したいプロジェクトに向いています。

  • bull:

    Redis を使い、UIダッシュボードや豊富な機能(再試行、遅延、優先度)が必要なレガシーまたは既存プロジェクト向けです。ただし、APIが古く、新規プロジェクトでは bullmq の方が推奨されます。

  • kue:

    非推奨のライブラリです。GitHub および npm で明確に deprecated と記載されており、最後の更新は2018年です。新規プロジェクトでは絶対に使用せず、代わりに bullmqbee-queue を検討してください。

bullmq のREADME




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

Read the documentation

Follow Us 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.