If what i understand is correct, processing background tasks is a good way to free the main thread of cpu bound tasks.
What i don't get is what is used by systems like bull or kue to run the tasks out of the main thread.
Do they use threads ? Do they require an entire node process fork? Do they spawn child processes?
Bull is based on Redis which handles in it's own process the handling and Queuing of data for these jobs. It is a lightweight, robust and fast job processing queue. It uses redis for persistence, so the queue is not lost if the server goes down for any reason.
the internal implementation of the Job can be seen here
The same is with Kue module which is a priority job queue backed by redis processes, built for node.js. The background tasks are powered by Redis.
This means that these module depends on Redis external process that enables different creating background jobs.
Job-specific events are fired on the Job instances via Redis pubsub:
enqueue
the job is now queuedpromotion
the job is promoted from delayed state to queuedprogress
the job's progress ranging from 0-100failed attempt
the job has failed, but has remaining attempts yetfailed
the job has failed and has no remaining attemptscomplete
the job has completedremove
the job has been removedThe delayed Jobs are powered by Redis Queue which notifies/triggers back the callbacks in the module.