Skip to content

Rate Limiting

Control the rate at which jobs are processed.

Rate Limit

Limit jobs per time window:

Terminal window
# CLI
bunqueue rate-limit set emails 100 # 100 jobs/second
bunqueue rate-limit clear emails

Concurrency Limit

Limit concurrent active jobs:

Terminal window
# CLI
bunqueue concurrency set emails 5 # Max 5 concurrent
bunqueue concurrency clear emails

Embedded Mode

In embedded mode, control throughput using worker concurrency:

const queue = new Queue('emails', { embedded: true });
// Control processing rate with worker concurrency
const worker = new Worker('emails', processor, {
embedded: true,
concurrency: 5, // Max 5 parallel jobs
});

For time-based rate limiting in embedded mode, implement it in your processor:

import { Ratelimit } from '@upstash/ratelimit'; // or similar
const ratelimit = new Ratelimit({ ... });
const worker = new Worker('emails', async (job) => {
await ratelimit.limit('email-send'); // External rate limiter
await sendEmail(job.data);
}, { embedded: true });