
A simple, fast, robust job/task queue for Node.js, backed by Redis.
- Simple: ~1000 LOC, and minimal dependencies.
- Fast: maximizes throughput by minimizing Redis and network overhead. Benchmarks well.
- Robust: designed with concurrency, atomicity, and failure in mind; full code coverage.
const Queue = require('bee-queue');
const queue = new Queue('example');
const job = queue.createJob({x: 2, y: 3});
job.save();
job.on('succeeded', (result) => {
console.log(`Received result for job ${job.id}: ${result}`);
});
// Process jobs from as many servers or processes as you like
queue.process(function (job, done) {
console.log(`Processing job ${job.id}`);
return done(null, job.data.x + job.data.y);
});
Introduction
Bee-Queue is meant to power a distributed worker pool and was built with short, real-time jobs in mind. A web server can enqueue a job, wait for a worker process to complete it, and return its results within an HTTP request. Scaling is as simple as running more workers.