Package Exports
- power-queues
Readme
power-queues
High-Performance Redis Streams Queue for Node.js
Ultra-fast, fault-tolerant, Lua-optimized distributed task queue built on Redis Streams.
Supports bulk XADD, idempotent jobs, retries, DLQ, stuck-task recovery, batching, and consumer groups.
Designed for large-scale microservices, telemetry pipelines, and high-load systems.
๐ Documentation
Full documentation is available here:
๐ https://power-queues.docs.ihor.bielchenko.com
๐ Features
- โก Bulk XADD โ send thousands of tasks in a single Redis call
- ๐ Retries & attempt tracking
- ๐ง Idempotent job execution (Lua locks, TTL, start/done keys)
- ๐งน Stuck task recovery (XAUTOCLAIM + Lua-based recovery)
- ๐ Consumer groups + batching
- ๐ฅ Dead Letter Queue (DLQ)
- ๐ Stream trimming, approx/exact maxlen, minid window
- ๐งฑ Fully async, high-throughput, production-ready
๐ฆ Installation
npm install power-queues๐งช Quick Start
import { QueueService } from './queue.service';
const queue = new QueueService();
// Add tasks
await queue.addTasks('my_queue', [
{ payload: { foo: 'bar' } },
{ payload: { a: 1, b: 2 } },
]);
// Run worker
queue.runQueue();๐ง Add Tasks (Bulk)
await queue.addTasks('mass_polling', largeArray, {
approx: true,
minidWindowMs: 30000,
maxlen: largeArray.length,
});๐๏ธ Worker Hooks
You can override:
onExecuteonSuccessonErroronRetryonBatchErroronSelectedonReady
Example:
async onExecute(id, payload) {
console.log('executing', id, payload);
}๐งฑ Architecture Overview
Producer โ Redis Stream โ Consumer Group โ Worker โ DLQ (optional)- Redis Streams store tasks
- Lua scripts handle trimming, idempotency, stuck recovery
- Workers fetch tasks via XREADGROUP or Lua select
- Tasks executed, ACKed, or sent to DLQ
๐๏ธ Dead Letter Queue (DLQ)
Failed tasks after workerMaxRetries automatically go to:
<stream>:dlq๐งฉ Idempotency
Guaranteed by 3 keys:
doneKeylockKeystartKey
This prevents double-execution during retries, crashes, or concurrency.
๐ Performance
- 10,000+ XADDs/sec
- Bulk mode: 50,000 operations in one request
- Extremely low CPU usage due to Lua trimming
๐ท๏ธ SEO Keywords
redis streams, redis queue, task queue, job queue, nodejs queue, nestjs queue,
bulk xadd, distributed queue system, background jobs, retries, dlq,
idempotency, redis lua scripts, microservices, high-performance queue,
high-throughput, batching, concurrency control๐ License
MIT