I have a web server that has a Node process running on it, managed by pm2 and the web server has 16 available cores.
The Node process manages a queue of tasks utilising the async module. This queue of tasks, depending on the number of events coming in, can grow to over 10,000 in the event of a disconnection between the Node process and the service it interacts with.
The queue will maintain this list of tasks in the event of a disconnection, and then when the connection is re-established, the queued tasks are then executed.
The docs say this...
Tasks added to the queue are processed in parallel (up to the concurrency limit). If all workers are in progress, the task is queued until one becomes available. Once a worker completes a task, that task's callback is called.
My questions are these...
If the queue had 10,000 tasks in it, and I set the concurrency level to 1, am I right in thinking that these will essentially be executed 1 at a time? If so, I guess this means that if new tasks are added, this queue could potentially never be fully drained?
If I was to set the concurrency value to 16, would it essentially run 16 tasks in parallel, making use of each CPU core? Or is the concurrency managed by something else?
How are tasks ran in parallel? My understanding is that a singe Node process can only utilise one core at a time because it's single threaded.
Am I totally missing the point as to how the async modules manages parallel tasks?!
Thanks in advance you clever bunch!