A distributed task queue built with Node.js and Redis to handle heavy background jobs (like PDF generation) asynchronously without blocking the main Express server.
It uses the Competing Consumers pattern, meaning you can spin up multiple worker processes to handle the queue in parallel.
- Backend: Node.js, Express
- Message Broker: Redis
- PDF Generation: PDFKit
- The Express Server accepts incoming tasks and pushes them into a Redis queue. It immediately returns a 202 Accepted status to the client.
- The Workers listen to the Redis queue, pull tasks off sequentially using atomic commands, and process the heavy PDF generation completely in the background.
Run this command in your terminal:
npm installMake sure your local Redis server is running.
Run this command in your terminal:
node server.jsRun this command in a separate terminal:
node worker.js