0

for a application I am currently developing, I need to start instances of a shared library in parallel.

As I want to have fine-grained control over the amount of parallel instances (-license of library restricts amount of parallelism to a fixed amount of threads), I am wondering if there's a easy way to create&maintain a own thread pool in the native module?

Thanks!

1 Answers1

0

Basically we must set the UV_THREADPOOL_SIZE environment variable before the thread pool is created.

This can be done in three ways:

  1. Putting this line in your .bashrc file will affect all the opened node processes under that user

    export UV_THREADPOOL_SIZE=10
    
  2. Set it before the process is open

    UV_THREADPOOL_SIZE=10 node myscript.js
    
  3. Set it inside the javascript, in the first line:

    process.env.UV_THREADPOOL_SIZE = 10;
    
Bernardo Ramos
  • 4,048
  • 30
  • 28