Bull-Ish Your Queues With BullMQ

Bookmark
Rate this content

Ever faced a situation where you desperately needed a queue, but traditional options were off the table? My team ran into this exact problem. After a lot of experimentation, we discovered a unique solution using Redis and BullMQ. This talk will share our journey – from the frustration of limited queueing options to building a highly scalable, lightning-fast system. We'll show you how we overcame the obstacles and achieved incredible results with Redis and BullMQ.

This talk has been presented at Node Congress 2025, check out the latest edition of this JavaScript Conference.

FAQ

Luca Del Pupo is a senior software developer at NearForm, a JavaScript and TypeScript enthusiast, and an author of tech posts for TechP. He also enjoys running, hiking, and taking care of his neighbors' cats.

The main topic of Luca Del Pupo's talk was queues and Boolean Queue (BoolMQ), focusing on queue systems in software development.

The team needed a queue system that could handle multiple queues to decouple or decentralize tasks but were initially provided with only one AWS SQS queue.

The team considered using Posgas SQL with the pgboss npm package and Elastic Cache with the BoolMQ npm library for their queue system.

The team chose BoolMQ over pgboss because pgboss would increase the database load, and their database was already under pressure at times.

Key features of BoolMQ include creating queues, handling data with workers, job creation, flow creation, parallelism, and concurrency. It also supports OpenTelemetry and provides a UI dashboard.

The cons of using BoolMQ include dependency on Redis, which if shut down can lead to data loss, and the need to learn a new library.

BoolMQ can be integrated with OpenTelemetry by setting up OpenTelemetry in the Node.js environment and using the BullMQ Hotel package to track telemetry.

Using Redis with BoolMQ allows for easy scaling, as Redis can scale itself if set up correctly, and it supports creating multiple instances or setting different concurrency levels for workers.

BoolMQ is an npm library that implements a fast and robust queue system on top of Redis, suitable for creating microservices architecture and handling queues efficiently.

Luca Del Puppo
Luca Del Puppo
23 min
17 Apr, 2025

Comments

Sign in or register to post your comment.
Video Summary and Transcription
Hello, and welcome to this talk where I talk about queues and Boolean Queue. Today I want to tell you a story of a team working on a client project that needed to handle a simple queue. They approached the platform team for help, but were only given one queue, which wasn't enough. The team had to find a solution using the tools they already had, such as Posgas SQL and Elastic Cache. The first possible solution was pgboss. If you don't know pgboss, it is a simple npm package that you can install in your node application and basically create a sort of queue system on top of Posgas SQL. And expose an API to call the queues and handle the queues inside of your application. The only solution left is Elastic Cache and Redis. And in this particular scenario, what shines is BoolMQ. BoolMQ is a simple npm library that implements a fast and robust queue system on top of Redis. It can be used to decouple your code and create a microservices architecture. You can create a flow by depending on different queues and creating the result based on each queue's result. Out of the box, BoolMQ provides parallelism and concurrency. Additionally, you can have OpenTelemetry set up and a UI dashboard for queue monitoring. To create a PullMQ queue, provide a name and a connection string to Redis. The code includes a run method that continuously pushes new temperatures into the queue. The consumer uses a worker to handle data and execute queries. Close the connection when closing the Node.js process. Run the publisher to push data and the consumer to receive data. Create multiple publishers or consumers as needed. The second demo shows how to set up OpenTelemetry in your Node.js environment to track what happens inside your queues. Use BullMQ Hotel and the BullHotel instance to track telemetry for your queues. The last demo demonstrates the use of Fastify with BullMQ to create a UI for managing queues. You can do whatever you want with OpenTelemetry. The last demo showcases a Fastify application within the UI. Fastify is a simple framework for handling Node.js APIs. Set up Fastify using the Fastify adapter exposed by BullMQ, BullBoard. Expose the '/UI' API to show the UI in the server. The UI allows you to interact with the queues and view completed items. BullMQ is a straightforward solution for handling queues and can be easily scaled using Redis. For most cases, using a queue is necessary and well-documented. However, it relies on Redis, which means data loss if Redis goes down. Additionally, you'll need to learn another library. Thank you for listening!
Video transcription and chapters available for users with access.