---
title: "How to migrate from BullMQ to Trigger.dev for durable AI agents"
description: "Migrate AI jobs from BullMQ to Trigger.dev one job type at a time: a BullMQ to Trigger.dev API mapping, runnable SDK v4 code, side-by-side rollout, trade-offs."
date: 2026-11-19
---

**To migrate from BullMQ to Trigger.dev, move one job type at a time: turn its worker's processor into a Trigger.dev task, switch that job's `queue.add()` call to `tasks.trigger()`, let the old queue drain, then delete the worker.** It's worth doing once a job that used to take 200 milliseconds has become an agent that makes 15 LLM calls and runs for 8 minutes.

This guide is for TypeScript and Node.js teams running AI work (LLM calls, agents, document processing) on BullMQ or a similar queue, who are hitting stalled jobs, lost progress on deploy, retry storms at peak load, or no visibility into what a long job is doing. It shows how to move that work to [Trigger.dev](https://trigger.dev), the open source platform for durable AI agents and workflows in TypeScript, one job type at a time, without a big-bang rewrite.

Trigger.dev publishes this page, and it links to docs.bullmq.io and our own docs so you can check the details. For the head-to-head feature comparison, see [Trigger.dev vs BullMQ](https://trigger.dev/vs/bullmq). This page is the migration guide.

## TL;DR

- BullMQ is a good queue, and it's still the right tool for short, high-volume jobs. AI jobs strain it in specific ways: a worker renews each job's [lock](https://docs.bullmq.io/api/interfaces/v6.WorkerOptions.html) while its event loop is free, so a CPU-heavy step that blocks the loop, or a process that gets killed, leaves the job marked as [stalled](https://docs.bullmq.io/guide/workers/stalled-jobs), a deploy can end a job that runs longer than your [shutdown grace period](https://docs.bullmq.io/guide/going-to-production), and multi-step jobs need [step state you track by hand](https://docs.bullmq.io/patterns/process-step-jobs).
- Moving a BullMQ job to Trigger.dev is mostly mechanical: the processor becomes a [`task`](https://trigger.dev/docs/tasks/overview)'s `run()`, `queue.add()` becomes [`tasks.trigger()`](https://trigger.dev/docs/triggering), `attempts`/`backoff` become `retry`, `jobId` becomes an [`idempotencyKey`](https://trigger.dev/docs/idempotency), Pro groups become a [`concurrencyKey`](https://trigger.dev/docs/concurrency), and job schedulers become [`schedules.task`](https://trigger.dev/docs/tasks/scheduled).
- Migrate incrementally. Run both systems side by side, move one job type at a time by switching its `queue.add()` call in your existing API route to `tasks.trigger()`, drain the old queue, then delete its worker. Keep Redis if anything else uses it.
- On Trigger.dev Cloud there are no workers to run and no Redis to manage. Runs are [locked to the version they started on](https://trigger.dev/docs/deployment/overview), so a deploy doesn't kill them, and waits are [checkpointed](https://trigger.dev/docs/wait) so they don't hold a machine or a concurrency slot.
- What doesn't change: a retry still runs `run()` [from the top](https://trigger.dev/docs/errors-retrying), so side effects still need idempotency keys. And Trigger.dev has no time-based rate limiter, [only concurrency limits](https://trigger.dev/docs/concurrency), costs [per run and per compute second](https://trigger.dev/pricing), and adds startup latency that an always-on worker doesn't have.
- Python and Celery teams: Trigger.dev tasks are TypeScript. Python runs as [scripts via a build extension](https://trigger.dev/docs/config/extensions/pythonExtension). If your codebase is Python, staying on Celery or moving to Temporal's Python SDK is likely the better fit.

## The same AI job on BullMQ and on Trigger.dev

Here's a typical AI job: summarize an uploaded document with an LLM, with retries, a cap on parallel LLM calls, and per-tenant fairness. First, the BullMQ version you probably have today (the options shown are the same in BullMQ v5 and v6):

```ts
// queue.ts
import { Queue } from "bullmq";

export const connection = { host: process.env.REDIS_HOST!, port: 6379 };

export const summarizeQueue = new Queue("summarize-document", { connection });
```

```ts
// app/api/documents/route.ts (the producer)
import { summarizeQueue } from "@/queue";

export async function POST(request: Request) {
  const { documentId, tenantId } = await request.json();

  const job = await summarizeQueue.add(
    "summarize",
    { documentId, tenantId },
    {
      jobId: `summarize-${documentId}`, // a duplicate jobId is ignored
      attempts: 5,
      backoff: { type: "exponential", delay: 2_000 },
    }
  );

  return Response.json({ jobId: job.id });
}
```

```ts
// worker.ts (a separate long-running process you deploy and scale)
import { Worker } from "bullmq";
import { generateText } from "ai";
import { openai } from "@ai-sdk/openai";
import { connection } from "./queue";
import { loadDocument, saveSummary } from "./lib/documents";

const worker = new Worker(
  "summarize-document",
  async (job) => {
    const doc = await loadDocument(job.data.documentId);
    const { text } = await generateText({
      model: openai("gpt-6-luna"),
      prompt: `Summarize this document in 5 bullet points:\n\n${doc.text}`,
    });
    await saveSummary(job.data.documentId, text);
    return { length: text.length };
  },
  {
    connection,
    concurrency: 10, // per worker process
    limiter: { max: 50, duration: 60_000 }, // global: 50 jobs a minute
    // The 30s default lockDuration is fine here: the lock renews while the event loop is free,
    // so a long LLM call that's waiting on the network doesn't stall. CPU-heavy steps can.
  }
);

process.on("SIGTERM", async () => {
  await worker.close(); // waits for active jobs, with no built-in timeout
  process.exit(0);
});
```

Now the same job on Trigger.dev, using the current `@trigger.dev/sdk` v4 ([4.7.0 or later](https://trigger.dev/changelog/multiple-concurrency-limits) for the `concurrency` option). It assumes a project created with `npx trigger.dev@latest init`, with `ai` and `@ai-sdk/openai` installed:

```ts
// trigger/summarize-document.ts
import { AbortTaskRunError, concurrencyLimit, logger, task } from "@trigger.dev/sdk";
import { generateText } from "ai";
import { openai } from "@ai-sdk/openai";
import { loadDocument, saveSummary } from "../lib/documents";

// One pool shared by every task that calls the LLM provider.
export const llmLimit = concurrencyLimit({ name: "llm", total: 50 });

export const summarizeDocument = task({
  id: "summarize-document",
  // Each tenant runs at most 5 at once, and every run also counts toward the shared LLM pool.
  concurrency: [{ perKey: 5 }, llmLimit],
  retry: { maxAttempts: 5, factor: 2, minTimeoutInMs: 2_000, maxTimeoutInMs: 60_000, randomize: true },
  maxDuration: 900, // compute seconds; Trigger.dev waits don't count
  run: async (payload: { documentId: string; tenantId: string }) => {
    const doc = await loadDocument(payload.documentId);
    if (!doc) {
      // A missing document won't appear on retry, so fail now instead of retrying.
      throw new AbortTaskRunError(`Document ${payload.documentId} not found`);
    }

    logger.info("Summarizing", { documentId: payload.documentId, chars: doc.text.length });

    const { text } = await generateText({
      model: openai("gpt-6-luna"),
      prompt: `Summarize this document in 5 bullet points:\n\n${doc.text}`,
    });

    await saveSummary(payload.documentId, text);
    return { length: text.length };
  },
});
```

```ts
// app/api/documents/route.ts (same route, new producer)
import { tasks } from "@trigger.dev/sdk";
import type { summarizeDocument } from "@/trigger/summarize-document";

export async function POST(request: Request) {
  const { documentId, tenantId } = await request.json();

  const handle = await tasks.trigger<typeof summarizeDocument>(
    "summarize-document",
    { documentId, tenantId },
    {
      idempotencyKey: `summarize-${documentId}`, // a second trigger returns the existing run
      concurrencyKey: tenantId, // this tenant's own pool under perKey: 5
      tags: [`tenant:${tenantId}`],
    }
  );

  return Response.json({ runId: handle.id });
}
```

There's no `worker.ts`. You deploy the task with `npx trigger.dev@latest deploy`, set `TRIGGER_SECRET_KEY` in your app, and Trigger.dev runs it. The route imports the task as a `type` only, so the task code isn't bundled into your app (the [triggering docs](https://trigger.dev/docs/triggering) recommend this).

## Signs your task queue keeps failing under AI workloads

None of these are bugs in BullMQ. They're what happens when a queue built for short jobs starts carrying jobs that take minutes, call slow external APIs and wait on other systems. If you recognize three or more, it's worth moving those job types.

**CPU-heavy steps get marked as stalled.** A BullMQ worker holds a lock on each active job and renews it on a timer, so a job that's waiting on the network, like a 3-minute LLM call, keeps its lock for as long as it runs. The default `lockDuration` and `stalledInterval` are both 30 seconds, and `maxStalledCount` is 1 ([WorkerOptions](https://docs.bullmq.io/api/interfaces/v6.WorkerOptions.html)). The lock lapses when the worker can't renew it: the docs name CPU-heavy work that doesn't return control to the event loop, or the process dying, as the causes ([stalled jobs](https://docs.bullmq.io/guide/workers/stalled-jobs)). Parsing a 300-page PDF or tokenizing a large prompt in the same job as the LLM call is what that looks like. A stalled job goes back to waiting, and once it has hit the stall limit it's moved to failed. If you've raised `lockDuration` to several minutes to stop this, that's the first sign: it papers over the blocking step and makes a real stall take longer to notice. BullMQ's own fix is a [sandboxed processor](https://docs.bullmq.io/guide/workers/sandboxed-processors), which runs the job in a separate process so the worker can keep renewing its locks.

**Deploys interrupt agent runs.** BullMQ's [production guide](https://docs.bullmq.io/guide/going-to-production) says to close workers on SIGTERM, and notes that this reduces stalled jobs but can't eliminate them, because a job may run longer than the server's grace period. `worker.close()` waits for active jobs with no built-in timeout ([graceful shutdown](https://docs.bullmq.io/guide/workers/graceful-shutdown)), so a 10-minute agent run and a 30-second container grace period don't fit together. The run is killed, picked up as stalled, and starts again from the top.

**You're storing step state by hand.** BullMQ's documented [process step jobs pattern](https://docs.bullmq.io/patterns/process-step-jobs) saves a `step` field with `job.updateData()` after each step, so a retry resumes at the right place. Waiting mid-job means `job.moveToDelayed()` plus throwing a `DelayedError`, and waiting on child jobs means `moveToWaitingChildren()` plus a `WaitingChildrenError`. It works. But if half your processor is a `switch` on `job.data.step`, you're building a workflow engine inside a queue.

**Peak load turns into a retry storm.** When an LLM provider starts returning 429s, workers that each retry on their own backoff schedule pile on. BullMQ has tools for this: its `limiter` is [global across workers](https://docs.bullmq.io/guide/rate-limiting), and its manual rate limit lets a worker that gets a 429 call `worker.rateLimit(ms)` and throw `Worker.RateLimitError()`, which pauses the queue and puts the job back in waiting without using an attempt. Per-tenant fairness, where one customer's 5,000-document upload doesn't starve everyone else, needs [groups](https://docs.bullmq.io/bullmq-pro/groups), which are in BullMQ Pro.

**Jobs wait on people or other systems.** An agent that needs a human approval, or a batch job at a provider that takes 2 hours, either holds a worker slot the whole time or gets split into delayed jobs and state you persist yourself.

**You can't see inside a long job.** When a job fails at minute 7, you want to see which LLM call failed, with its input, and what happened on each retry. BullMQ records job state and the error, and gives you `job.log()`, `job.updateProgress()` and an [OpenTelemetry integration](https://docs.bullmq.io/guide/telemetry) to build on. The per-step picture of each LLM call comes from whatever logging and tracing you wire up.

**Redis is now critical infrastructure.** BullMQ requires `maxmemory-policy` set to `noeviction`, calling it "the only setting that guarantees the correct behavior of the queues", and recommends enabling AOF persistence ([going to production](https://docs.bullmq.io/guide/going-to-production)). That's fine to run, but it's a database that now holds your in-flight agent state. BullMQ also ships an optional [PostgreSQL backend](https://docs.bullmq.io/guide/postgresql), though Redis is still the default.

### Jobs that belong on BullMQ

Keep BullMQ for jobs that are short, frequent and simple: sending emails, cache invalidation, webhook fan-out, anything that finishes in well under a second and runs millions of times a day. An always-on worker that pulls the next job straight from Redis starts work sooner than a run that has to start on a separate machine, you control every part of the stack, and development runs against a local Redis. Plenty of teams run both: BullMQ for the small fast jobs, Trigger.dev for the long and AI-shaped ones.

## How BullMQ APIs map to Trigger.dev

| BullMQ | Trigger.dev | Notes |
| --- | --- | --- |
| `new Queue("name", { connection })` | Nothing to create | Each task gets its own [queue](https://trigger.dev/docs/queues) on deploy. No Redis connection. |
| `new Worker("name", processor, opts)` | `task({ id, run })` | The processor body becomes `run()`. No worker process to deploy or scale on Cloud. |
| `queue.add(name, data, opts)` | `tasks.trigger<typeof t>("id", payload, opts)` or `t.trigger(payload)` | Returns a handle with the run `id`. [Triggering docs](https://trigger.dev/docs/triggering). |
| `queue.addBulk(jobs)` | `tasks.batchTrigger<typeof t>("id", items)` or `t.batchTrigger(items)` | Up to 1,000 runs per call. |
| `attempts: 5`, `backoff: { type: "exponential", delay: 2000 }` | `retry: { maxAttempts: 5, factor: 2, minTimeoutInMs: 2000, maxTimeoutInMs, randomize }` | Default is 3 attempts ([task options](https://trigger.dev/docs/tasks/overview)). |
| `throw new UnrecoverableError(...)`, or a `backoffStrategy` returning `-1` | `throw new AbortTaskRunError(...)` | Fails the run without retrying ([errors and retrying](https://trigger.dev/docs/errors-retrying)). |
| Worker `concurrency: 10` (per worker, so 10 × your worker count) | `concurrency: { total: 10 }` on the task | Trigger.dev's limit counts every executing run of the task, wherever it runs. |
| `queue.setGlobalConcurrency(4)` | `concurrency: { total: 4 }` | Same idea. Share one limit across tasks with `concurrencyLimit({ name, total })`. |
| `limiter: { max: 50, duration: 60000 }`, `worker.rateLimit(ms)` | No direct equivalent | Trigger.dev limits concurrency, not jobs per time window, and has no queue-wide pause on a 429. See the limits section. |
| Pro `group: { id: tenantId }` | `concurrencyKey: tenantId` with `concurrency: { perKey: n }` | Each key gets its own pool ([concurrency](https://trigger.dev/docs/concurrency)). |
| `jobId` (duplicate ignored) | `idempotencyKey` (returns the existing run) | Keys last 30 days by default and are cleared if the run fails; set `idempotencyKeyTTL` to change the window ([idempotency](https://trigger.dev/docs/idempotency)). |
| `deduplication: { id, ttl, extend: true, replace: true }` with a matching `delay` (debounce mode) | `debounce: { key, delay, mode: "trailing", maxDelay }` | [Debounce](https://trigger.dev/docs/triggering#debounce) pushes a delayed run back while triggers keep arriving. |
| `delay: 5000` (milliseconds) | `delay: "5s"` or a `Date` | Duration strings like `"1h"` and `"1h52m18s"` ([delay](https://trigger.dev/docs/triggering)). |
| `priority: 1` (1 to 2,097,151, lower runs first) | `priority: 10` (higher runs first) | Trigger.dev priority is a head start in seconds over runs with no priority. |
| `upsertJobScheduler(id, { pattern, tz }, template)` | `schedules.task({ id, cron: { pattern, timezone, window: "0m" } })` | Declarative schedules sync on deploy. New schedules get a default 60-minute spreading window, so set `window: "0m"` to keep the exact cron time on paid plans (Free treats it as 60 minutes) ([scheduled tasks](https://trigger.dev/docs/tasks/scheduled)). |
| v5 `queue.add(name, data, { repeat: { pattern } })` | `schedules.task({ id, cron })` | BullMQ v6 [removed `repeat`](https://docs.bullmq.io/guide/jobs/repeatable) in favor of job schedulers. Both map to a scheduled task. |
| `FlowProducer` + `job.getChildrenValues()` | `child.triggerAndWait()` / `child.batchTriggerAndWait()` | The parent is checkpointed while children run. |
| `job.waitUntilFinished(queueEvents)` | `triggerAndWait()` inside a task, or `runs.subscribeToRun(id)` from your backend | Realtime streams the run's status as it changes ([Realtime](https://trigger.dev/docs/realtime/backend/overview)). |
| `job.updateProgress(50)` | `metadata.set("progress", 50)` | Subscribers get metadata updates in real time ([run metadata](https://trigger.dev/docs/runs/metadata)). |
| `job.moveToDelayed()` + `DelayedError` | `await wait.for({ minutes: 10 })` | Plain `await` in the middle of `run()` ([wait.for](https://trigger.dev/docs/wait-for)). |
| `job.updateData({ step })` step pattern | Ordinary code, child tasks and waits | Each child task gets its own retries. See "what doesn't change" for retry behavior. |
| `lockDuration`, `stalledInterval` | Heartbeats every 20 seconds; stalled after 5 minutes without one | Use `heartbeats.yield()` in tight CPU loops ([heartbeats](https://trigger.dev/docs/runs/heartbeats)). |
| `worker.close()` on SIGTERM | Nothing | Runs are locked to the deployed version they started on ([deployment](https://trigger.dev/docs/deployment/overview)). |
| Redis `noeviction`, AOF persistence | Nothing on Cloud | Self-hosted Trigger.dev runs its own Postgres and Redis ([self-hosting](https://trigger.dev/docs/self-hosting/overview)). |

Two rows deserve a second look. Priority runs in opposite directions: in BullMQ [a lower number is a higher priority](https://docs.bullmq.io/guide/jobs/prioritized), and in Trigger.dev a higher number starts sooner. And `jobId` and `idempotencyKey` behave differently once a job is gone: BullMQ [frees a job ID for reuse](https://docs.bullmq.io/guide/jobs/job-ids) once the job is removed (including through `removeOnComplete`), while a Trigger.dev idempotency key keeps returning the same run for 30 days unless you set a shorter TTL. If users can re-process the same document, put a version or content hash in the key.

## Schedules, waits and fan-out after the migration

The mapping table covers single jobs. Here's what the multi-job patterns look like on Trigger.dev, as complete files.

A BullMQ job scheduler such as `queue.upsertJobScheduler("nightly-resummarize", { pattern: "0 3 * * *", tz: "America/New_York" }, { name: "resummarize" })` becomes a scheduled task that fans out to the task above. One difference to know about: a new Trigger.dev schedule spreads its runs across a [default 60-minute window](https://trigger.dev/docs/tasks/scheduled) after the cron time, so set `window: "0m"` if the job has to start at 03:00 like the BullMQ scheduler did (on paid plans; Free treats it as 60 minutes):

```ts
// trigger/nightly-resummarize.ts
import { schedules } from "@trigger.dev/sdk";
import { summarizeDocument } from "./summarize-document";
import { listStaleDocuments } from "../lib/documents";

export const nightlyResummarize = schedules.task({
  id: "nightly-resummarize",
  // window: "0m" keeps the exact 03:00 start on paid plans; without it, runs spread over the next 60 minutes.
  cron: { pattern: "0 3 * * *", timezone: "America/New_York", window: "0m" },
  run: async (payload) => {
    // A batch takes up to 1,000 items; page through larger sets.
    const docs = await listStaleDocuments({ limit: 1_000 });
    if (docs.length === 0) return { triggered: 0 };

    await summarizeDocument.batchTrigger(
      docs.map((doc) => ({
        payload: { documentId: doc.id, tenantId: doc.tenantId },
        options: {
          concurrencyKey: doc.tenantId,
          // Scoped to this scheduled run, so a retry of this task doesn't trigger duplicates.
          idempotencyKey: `resummarize-${doc.id}-${payload.timestamp.toISOString()}`,
        },
      }))
    );

    return { triggered: docs.length };
  },
});
```

The `moveToDelayed` plus `DelayedError` pattern for polling a slow external job becomes a loop with `wait.for`. This one waits on an LLM provider's batch API for up to 24 hours:

```ts
// trigger/embed-corpus.ts
import { logger, task, wait } from "@trigger.dev/sdk";
import { getBatchStatus, importEmbeddings } from "../lib/embeddings";

export const embedCorpus = task({
  id: "embed-corpus",
  maxDuration: 600, // compute seconds; the waits below don't count
  run: async (payload: { batchId: string }) => {
    for (let check = 0; check < 144; check++) {
      const status = await getBatchStatus(payload.batchId);

      if (status === "completed") {
        const count = await importEmbeddings(payload.batchId);
        return { status, count };
      }
      if (status === "failed") throw new Error(`Batch ${payload.batchId} failed`);

      logger.info("Batch still running", { status, check });
      // The run is checkpointed while it waits, so it releases its machine and slot.
      await wait.for({ minutes: 10 });
    }

    throw new Error(`Batch ${payload.batchId} didn't finish in 24 hours`);
  },
});
```

On Trigger.dev Cloud, a `wait.for()` checkpoints the process and releases its concurrency slot, and waiting is free ([wait](https://trigger.dev/docs/wait)). If the thing you're waiting on is a person rather than a timer, use a [waitpoint token](https://trigger.dev/docs/wait-for-token) instead; our [human-in-the-loop guide](https://trigger.dev/human-in-the-loop-ai-agents) covers that in depth.

## How to migrate from BullMQ to Trigger.dev step by step

The goal is to never have a day where everything moves at once. You run BullMQ and Trigger.dev side by side, move one job type, watch it in production, then move the next.

**1. Pick the job type that hurts most.** Usually it's the one with a raised `lockDuration`, the one deploys keep interrupting, or the one with step state in `job.data`. Don't start with your highest-volume email job; it gains the least.

**2. Add Trigger.dev to the same repo.** Run `npx trigger.dev@latest init` in your existing project. It adds `@trigger.dev/sdk`, a `trigger.config.ts` and a `trigger` directory. If you run `npx trigger.dev@latest dev`, your tasks run locally against your dev environment, while your app and BullMQ workers keep running as before. Your existing `lib/` code is importable from tasks, so you don't copy business logic.

**3. Move the processor into a task.** Paste the worker's processor body into `run()`. Replace `job.data` with `payload`, map the job options with the table above, and delete any step-tracking code you no longer need (the retry section below covers what has to stay idempotent). Tasks run on Trigger.dev's machines, so any environment variables the processor reads have to be [set in Trigger.dev](https://trigger.dev/docs/deploy-environment-variables) too.

**4. Switch the producer behind a flag.** In the existing API route, keep the `queue.add()` call and add a `tasks.trigger()` path, chosen by an environment variable or feature flag. Route each job to exactly one system: an idempotency key in Trigger.dev doesn't know about a `jobId` in BullMQ, so sending the same job to both would run it twice.

```ts
// app/api/documents/route.ts during the migration
import { tasks } from "@trigger.dev/sdk";
import type { summarizeDocument } from "@/trigger/summarize-document";
import { summarizeQueue } from "@/queue";

const useTrigger = process.env.SUMMARIZE_ON_TRIGGER === "true";

export async function POST(request: Request) {
  const { documentId, tenantId } = await request.json();

  if (useTrigger) {
    const handle = await tasks.trigger<typeof summarizeDocument>(
      "summarize-document",
      { documentId, tenantId },
      { idempotencyKey: `summarize-${documentId}`, concurrencyKey: tenantId }
    );
    return Response.json({ runId: handle.id });
  }

  const job = await summarizeQueue.add(
    "summarize",
    { documentId, tenantId },
    { jobId: `summarize-${documentId}`, attempts: 5, backoff: { type: "exponential", delay: 2_000 } }
  );
  return Response.json({ jobId: job.id });
}
```

**5. Deploy and turn it on.** Run `npx trigger.dev@latest deploy` (or use [GitHub Actions](https://trigger.dev/docs/github-actions)), then flip the flag in staging, then production. Anything that polls job status needs updating too: a run's status comes from `runs.retrieve()` or a [Realtime subscription](https://trigger.dev/docs/realtime/backend/overview) instead of BullMQ's job getters.

**6. Drain the old queue.** Once nothing new is added, let the BullMQ workers finish what's left. `queue.getJobCounts("wait", "delayed", "active", "prioritized", "waiting-children")` tells you when it's empty ([getters](https://docs.bullmq.io/guide/jobs/getters)). Delayed jobs are easy to forget: a job added with a 7-day delay is still in Redis next week.

**7. Remove schedulers in the same release as their replacements.** A `schedules.task` with a `cron` is live as soon as it deploys, and a BullMQ job scheduler keeps firing until you remove it. Call `queue.removeJobScheduler(id)` ([manage job schedulers](https://docs.bullmq.io/guide/job-schedulers/manage-job-schedulers)), or `removeRepeatable()` for v5 `repeat` jobs, when you ship the new task, or the job runs twice.

**8. Delete the worker, then the queue's keys.** Remove the job type's worker from your deploy. When the queue is empty, `queue.obliterate()` deletes the queue and everything in it ([removing jobs](https://docs.bullmq.io/guide/queues/removing-jobs)); it refuses while jobs are active unless you pass `force`. It's scoped to that one queue, so it leaves the rest of a shared Redis instance alone.

**9. Decide what happens to Redis.** If Redis only existed for BullMQ, you can shut it down after the last job type moves. If you also use it for caching, sessions or your own rate limiting, keep it and drop the queue-specific settings once nothing depends on them. Trigger.dev Cloud doesn't need your Redis for anything.

**10. Repeat per job type.** Most teams move the long, AI-shaped jobs first and leave the short ones on BullMQ for a while, sometimes for good.

## What changes when you move from basic job queues to production AI agent infrastructure

**No workers to run.** On Trigger.dev Cloud, compute is included: you deploy tasks and Trigger.dev runs them on machines it manages. There's nothing to keep alive with PM2, Kubernetes or a process manager, and no autoscaling to configure. You pick a [machine size](https://trigger.dev/docs/machines) per task (or per run) when a job needs more memory.

**No Redis for the queue.** Queueing, retries, delays, schedules and idempotency live in Trigger.dev. On Cloud there's no Redis to size, persist or set an eviction policy on.

**Deploys don't kill runs.** When a run starts, it's locked to the current deployed version, and its retries stay on that version too ([deployment](https://trigger.dev/docs/deployment/overview)). New runs pick up the new version. A 40-minute agent run that started before your deploy finishes on the code it started with.

**Waits are checkpointed.** A `triggerAndWait` on a child task, a `wait.for` or a `wait.forToken` on an approval checkpoints the process and frees the machine; when the wait completes, the run is restored where it left off ([how it works](https://trigger.dev/docs/how-it-works)). Only executing runs count toward concurrency limits, so 500 runs waiting on an approval or a subtask don't block new ones.

**There's no lock to tune.** Trigger.dev detects stuck runs with heartbeats, the same idea as BullMQ's lock with a longer tolerance: one every 20 seconds, and a run is marked stalled after 5 minutes without one ([heartbeats](https://trigger.dev/docs/runs/heartbeats)). A long LLM call that's waiting on the network keeps heartbeating. Like a lock renewal, a heartbeat can't go out while a synchronous CPU loop blocks the event loop, so call `heartbeats.yield()` inside one.

**Every run has a trace.** The dashboard shows each run's logs, spans, payload, output and every retry attempt, and `logger` gives you structured logs you can search ([logging](https://trigger.dev/docs/logging)). You can add OpenTelemetry instrumentations in `trigger.config.ts`. The full observability comparison is on [/vs/bullmq](https://trigger.dev/vs/bullmq).

**Runs have no maximum duration,** but every project sets a default [`maxDuration`](https://trigger.dev/docs/runs/max-duration) in `trigger.config.ts`, which caps compute time (time spent in Trigger.dev waits doesn't count) and stops runaway jobs. Raise it per task for anything that legitimately runs long.

## What doesn't change, or gets harder

**A retry still starts `run()` from the top.** A retried BullMQ processor runs again from the start too. Trigger.dev doesn't replay or memoize steps. What it gives you instead is checkpointed waits, child tasks with their own retries, and [idempotency keys](https://trigger.dev/docs/idempotency): `idempotencyKeys.create()` inside a task is scoped to the run, so a retried parent gets the same child run back instead of triggering a new one. Anything that sends an email, charges a card or writes to another system still needs that provider's idempotency key, derived from something stable like `ctx.run.id`.

**There's no time-based rate limiter.** BullMQ's `limiter: { max, duration }` caps jobs per time window. Trigger.dev caps how many runs execute at once ([concurrency](https://trigger.dev/docs/concurrency)). If your LLM provider limits requests per minute, pick a concurrency limit that keeps you under it in practice, retry 429s with backoff, or keep a token bucket in your own code. There's also no equivalent of BullMQ's `worker.rateLimit()` for pausing a whole queue when the provider pushes back.

**Plan limits shape peak load.** On Trigger.dev Cloud ([limits](https://trigger.dev/docs/limits)):

- The API allows 1,500 requests per minute, so trigger in bulk with `batchTrigger()` instead of calling `trigger()` in a loop.
- Each queue can hold a capped number of queued runs (10,000 on Free, 250,000 on Hobby, 1,000,000 on Pro, in staging and production). Triggers to a full queue are rejected.
- A run that sits queued for 14 days without starting expires.
- Your environment's concurrency caps every limit you set. Free allows 20 runs at once in production, so `concurrencyLimit({ name: "llm", total: 50 })` behaves like 20 there.

**Self-hosting is a real trade-off.** Trigger.dev is [open source (Apache 2.0)](https://github.com/triggerdotdev/trigger.dev) and self-hostable with Docker or Kubernetes. A self-hosted install runs a webapp (with its own Postgres and Redis) and workers you operate, and warm starts, autoscaling and checkpoints are Cloud-only ([self-hosting](https://trigger.dev/docs/self-hosting/overview)). So self-hosted waits hold their machine, and you're back to running infrastructure, just different infrastructure than BullMQ.

**The cost model changes from fixed to per-use.** With BullMQ you pay for a Redis instance and worker machines whether they're busy or not. Trigger.dev Cloud bills a small fee per run plus compute by the second, with the per-second rate set by the [machine size](https://trigger.dev/docs/machines), on a free plan with monthly compute credit or a paid plan with more ([pricing](https://trigger.dev/pricing)). Time spent in Trigger.dev waits (approvals, subtasks, `wait.for`) is free. Which model costs less depends on the shape of your workload, so do the math on your own volumes against the pricing page and your current Redis and worker bill.

**Tiny jobs get slower to start.** A Trigger.dev run is dequeued and started on a machine, which takes longer than an always-on worker pulling the next job from Redis. Warm starts on Cloud and [`processKeepAlive`](https://trigger.dev/docs/config/config-file#process-keep-alive) reduce it. For a job that runs for minutes, that doesn't matter. For a 50-millisecond job on a hot path, keep BullMQ.

**Local development goes through the CLI.** `npx trigger.dev@latest dev` runs your tasks on your machine, connected to your Trigger.dev dev environment. BullMQ runs entirely against a local Redis.

## What agent frameworks integrate easily with your existing backend stack?

Any TypeScript agent framework runs inside a Trigger.dev task unchanged, because a task is an async function: the Vercel AI SDK (`generateText`, `streamText`), Mastra, the OpenAI Agents SDK (`@openai/agents`) and LangGraph JS all work. The framework decides what the agent does, and the task gives it retries, queues, checkpointed waits and a trace. We compared 7 frameworks and how each one pairs with a durable runtime in [Best AI agent frameworks for production](https://trigger.dev/production-ai-agent-frameworks-comparison).

On the backend side, you trigger tasks from wherever you call `queue.add()` today: a Next.js route handler, an Express or Fastify handler, a Remix action, a webhook receiver or another task. `tasks.trigger()` calls the Trigger.dev API, so the backend that triggers it can run on Vercel, in a container or in a serverless function, and services in other languages can use the [REST API](https://trigger.dev/docs/management/tasks/trigger).

## For Python and Celery teams

Trigger.dev tasks are written in TypeScript; there's no Python SDK for defining tasks. Python code runs as scripts from a TypeScript task through the [Python build extension](https://trigger.dev/docs/config/extensions/pythonExtension) and `python.runScript()` from `@trigger.dev/python`, which suits a TypeScript team with a few Python scripts (a PDF parser, a data-science step). If your workers, models and business logic are Python and your problem is Celery under AI workloads, you're better served by staying on [Celery](https://docs.celeryq.dev/en/stable/) and fixing the specific failure, using [BullMQ's Python package](https://docs.bullmq.io/python/introduction) if you want its queue model, or moving to [Temporal's Python SDK](https://docs.temporal.io/develop/python), which gives you durable workflows in the language you already write.

## Choosing between BullMQ, Trigger.dev and Temporal

| Your situation | Good fit |
| --- | --- |
| Short, high-volume jobs (emails, cache busting, webhooks), you're happy running Redis | Stay on BullMQ |
| TypeScript, AI jobs that run minutes to days, deploys interrupt them, you don't want to run workers | Trigger.dev Cloud |
| Mixed: lots of small fast jobs plus some long agent runs | BullMQ for the small jobs, Trigger.dev for the long ones |
| Polyglot services that need durable workflows, or you want each step replayed from history | Temporal ([comparison](https://trigger.dev/vs/temporal)) |
| Python codebase on Celery | Stay on Celery, or Temporal's Python SDK |
| Must run everything in your own cloud | BullMQ, or self-hosted Trigger.dev (without checkpoints) |

BullMQ's strength is control: a library, your Redis (or Postgres), your workers, and an always-on worker that picks up the next job without starting a machine. Temporal's strength is replay-based durability across many languages, with the trade that you write [deterministic workflow code](https://docs.temporal.io/workflow-definition#deterministic-constraints) and [run the Workers](https://docs.temporal.io/cloud/introduction) yourself, or in public preview as [Serverless Workers](https://docs.temporal.io/serverless-workers) on your own Lambda or Cloud Run. Trigger.dev's strength is plain async TypeScript with checkpointed waits and no workers or Redis to operate, with the trade of run-level retries, per-run pricing and startup latency.

## FAQs

- **How do I migrate from BullMQ to Trigger.dev without downtime?** Run both side by side. Add Trigger.dev to the same repo, move one job type's processor into a `task`, switch that job's `queue.add()` call to `tasks.trigger()` behind a flag, and let BullMQ drain the jobs already queued. Remove BullMQ job schedulers in the same release as their `schedules.task` replacements so nothing runs twice. Then repeat for the next job type.

- **We need to scale our AI agent workloads but our task queue keeps failing during peak loads. What should we change?** First find out which failure it is. Stalled jobs mean a worker couldn't renew a job's lock: a CPU-heavy step blocked the event loop, or the process was killed. A long LLM call that's waiting on the network keeps its lock. Lost work on deploy means jobs outlasting the shutdown grace period. Retry storms mean many workers retrying against a rate-limited LLM provider at once. On BullMQ, the fixes are sandboxed processors for CPU-heavy steps, a shutdown grace period longer than your longest job, and a manual rate limit on 429s. On Trigger.dev, runs stay on their version across deploys, heartbeats catch stuck runs, and concurrency limits per task, per tenant (`concurrencyKey`) and shared across tasks (`concurrencyLimit()`) cap how hard you hit the provider.

- **Do I still need Redis after moving to Trigger.dev?** Not for the jobs you move, if you're on Trigger.dev Cloud. Keep Redis if you use it for caching, sessions or anything else. Self-hosted Trigger.dev runs its own Redis and Postgres as part of the webapp.

- **What happens to in-progress jobs when I deploy on Trigger.dev?** They keep running. Each run is locked to the version that was current when it started, and its retries stay on that version. New runs use the new version.

- **Does Trigger.dev retry from the failed step?** No. A retry runs `run()` again from the top, the same as a retried BullMQ processor. Put risky steps in child tasks (each has its own retries, and the parent is checkpointed while they run), and give side effects idempotency keys so a retry doesn't repeat them.

- **Is Trigger.dev faster than BullMQ?** For starting tiny jobs, no. An always-on BullMQ worker picks up a job from Redis sooner than a run can start on a machine. Trigger.dev is built for jobs that run seconds to days, where startup time is a small fraction of the run.

- **We're migrating from a basic task queue to a scalable orchestration system. Do we have to rewrite our jobs?** Mostly not. A BullMQ processor is an async function, and so is a Trigger.dev task's `run()`. The work is mapping job options to task options, deleting worker and Redis setup, and replacing hand-rolled step state with child tasks and waits.

- **Can I use Trigger.dev from Python or with Celery?** Trigger.dev tasks are TypeScript. You can run Python scripts from a task with the Python build extension, but if your codebase is Python, staying on Celery or using Temporal's Python SDK is the better fit.
