Skip to content
Contents

Why Background ?

Background uses a intelligent polling based approach rather than event driven design like BullMQ. Backgrounds approach has both pros and cons. Backgrounds main goal is to create a extendible queue with runtime flexibility and give developers the freedom they want implementing to their own system. Event driven queues are primarly designed for a single runtime or database.

It's normal because each database has its own way of handling them.

Benefits of Background

  • Cross-Runtime Compatibility: Works across different JavaScript/TypeScript runtimes (Node.js, Bun)
  • Database Flexibility: Not tied to Redis-only infrastructure like many event-driven solutions
  • Lower Setup Complexity: Minimal configuration required to get started
  • Extensibility: Modular design makes it easier to adapt to different storage backends
  • Optimized Polling: Intelligently adjusts polling frequency based on job availability, significantly reducing database hits compared to naive polling
  • Simplified Mental Model: Polling-based architecture is easier to reason about and debug

Limitations of Background

  • Higher Latency: Small delay between job submission and processing (bounded by polling interval)
  • Database Load: More database operations than pure event-driven solutions (though optimized)
  • Resource Overhead: Slightly higher CPU usage due to polling mechanism
  • Not Ideal for High-Volume, Low-Latency: May not be the best choice when processing thousands of jobs per second with minimal delay requirements

When to Use Background

Background is ideal for:

  • Background job processing in web applications
  • Task scheduling with moderate throughput requirements
  • Systems that need to work across multiple database types
  • Projects where easy setup and maintenance are prioritized
  • Applications where job latency of a few milliseconds is acceptable

This libary is mostly designed for easily running managing background jobs. It's not recommended to try to use it as a way to achieve microservices.

If you plan to use a messaging solution for your microservices app, I would recommend using something like Cloud PubSub or Apache Kafka.

If people like Background, I do plan to build a event driven queue that uses pubsub mechanisms. But it will be harder to create a extendible one in that circumstance.