1

I have started experimenting in Node.js lately.

I'm currently setting up an app, which will handle multiple queues in parallel by utilising bull library, to run heavy jobs in the background.

I'm looking for an answer, which i hope i did not miss in the documentation.

**It's still kind of "blurry" to me, how this library is handling those tasks in parallel. **

So i have the following scenario:

  • 2 jobs are running at the same time, both of them are heavy and are taking some time to finish.

  • During the run of those 2 jobs, i can still use the rest of the
    application - The event loop is not blocked.

What i get from that, is, that probably something else handles those 2 jobs, since JavaScript is single-threaded What is this?

Any guidance or any advice will be highly appreciated!

https://github.com/OptimalBits/bull

Makis
  • 1,214
  • 3
  • 16
  • 40
  • 3
    Bull uses child_process.fork to spawn new processes. See https://github.com/OptimalBits/bull/blob/edfbd163991c212dd6548875c22f2745f897ae28/lib/process/child-pool.js#L3 and https://nodejs.org/api/child_process.html#child_process_child_process_fork_modulepath_args_options – Pete TNT Oct 13 '21 at 20:29
  • 2
    JS runtime is single-threaded but it doesn't mean you can't access [multithread API](https://nodejs.org/api/worker_threads.html) from it – Dmitrii Zolotuhin Oct 13 '21 at 20:30
  • Thank you both! Taking a look! – Makis Oct 13 '21 at 20:57

0 Answers0