Rate Limiting
Control the rate at which jobs are processed.
Rate Limit
Limit jobs per time window:
# CLIbunqueue rate-limit set emails 100 # 100 jobs/secondbunqueue rate-limit clear emailsConcurrency Limit
Limit concurrent active jobs:
# CLIbunqueue concurrency set emails 5 # Max 5 concurrentbunqueue concurrency clear emailsEmbedded Mode
In embedded mode, control throughput using worker concurrency:
const queue = new Queue('emails', { embedded: true });
// Control processing rate with worker concurrencyconst 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 });