Skip to content

Parallelism and Concurrency #2649

Answered by manast
andrew-sol asked this question in Q&A
Jul 14, 2024 · 2 comments · 2 replies
Discussion options

You must be logged in to vote

Question 1: Will it occupy 4 CPUs under high load or will it work the same way as a single worker instance with the concurrency = 4 and use only 1 CPU?

As NodeJS is single-threaded, if you instantiate several workers in the same NodeJS process then they will not use more than 1 CPU in total. You can use PM2 for example to start different NodeJS processes that will effectively run in parallel if you have enough CPU cores.

Question 2: If I run that setup on many separate machines connected to the same Redis, is it guaranteed that the same job won’t be picked up by two of them at the same time and processed twice (or more times) simultaneously?

BullMQ guarantees at least once semantics, …

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@andrew-sol
Comment options

Answer selected by andrew-sol
Comment options

You must be logged in to vote
1 reply
@manast
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants