Friday 9 June 2017

How to set thread size of libuv in nodejs?

  1. I have write a demo in nodejs like this:

hello.js:

var http = require(‘http’);
while(true){
    console.log(process.env.UV_THREADPOOL_SIZE);
}

  1. I monitor the process and threads with 'pstree -p | grep node' after starting the program above.

  2. I have tried 3 ways to edit thread size but none of them works: 1) Set the paramters when starting: 'UV_THREADPOOL_SIZE=100 node hello.js' 2) add path in the etc/profile and reboot the system:export UV_THREADPOOL_SIZE=100 3) add 'process.env.UV_THREADPOOL_SIZE=100' in the code.

  3. the results of the monitor are the same:

enter image description here

There is only 5 threads work in the node process (4 are work threads and 1 is loop thread)

My nodejs is v6.9.x. Have anyone used this successfully?



via Alex.Xing

No comments:

Post a Comment