One of the changes made by Ben Noordhius in Node v0.10.0 was to "honor UV_THREADPOOL_SIZE environment variable" in Unix. The "threadpool.c" source file seems to do just that.
Ben Noordhius在Node v0.10.0中做出的改变之一是在Unix中“尊重UV_THREADPOOL_SIZE环境变量”。 “threadpool.c”源文件似乎就是这样做的。
If I don't set this env variable, I can verify that I am limited to a threadpool of 4 threads, which is the default size of the threadpool.
如果我没有设置这个env变量,我可以验证我是否仅限于4个线程的线程池,这是线程池的默认大小。
But I set this environment variable on my Linux server to 64 and then restart Node, but I still seem to be limited, seemingly to a threadpool of size of 5?!
但我在我的Linux服务器上将此环境变量设置为64,然后重新启动Node,但我似乎仍然有限,似乎是一个大小为5的线程池?!
Does this make any sense to anyone? Thanks!
这对任何人都有意义吗?谢谢!
2 个解决方案
#1
7
It seems that you must set it the var with node command or from inside the node program. Execute it like:
您似乎必须使用node命令或从节点程序内部将其设置为var。执行它像:
UV_THREADPOOL_SIZE=64 node
or modify from program :
或从程序修改:
process.env.UV_THREADPOOL_SIZE=64
//then execute some function that requires threadpool
require('fs').readFile('testing',function(){});
Testing threads:
ps -Lef | grep "\<node\>" | wc -l
67
#2
1
If you're running a Windows OS and running via a .js file you'll need to set the UV_THREADPOOL_SIZE
prior to calling the script via node.
如果您正在运行Windows操作系统并通过.js文件运行,则需要在通过节点调用脚本之前设置UV_THREADPOOL_SIZE。
Example: SET UV_THREADPOOL_SIZE = 2 && node my-file-to-run.js
示例:SET UV_THREADPOOL_SIZE = 2 && node my-file-to-run.js
#1
7
It seems that you must set it the var with node command or from inside the node program. Execute it like:
您似乎必须使用node命令或从节点程序内部将其设置为var。执行它像:
UV_THREADPOOL_SIZE=64 node
or modify from program :
或从程序修改:
process.env.UV_THREADPOOL_SIZE=64
//then execute some function that requires threadpool
require('fs').readFile('testing',function(){});
Testing threads:
ps -Lef | grep "\<node\>" | wc -l
67
#2
1
If you're running a Windows OS and running via a .js file you'll need to set the UV_THREADPOOL_SIZE
prior to calling the script via node.
如果您正在运行Windows操作系统并通过.js文件运行,则需要在通过节点调用脚本之前设置UV_THREADPOOL_SIZE。
Example: SET UV_THREADPOOL_SIZE = 2 && node my-file-to-run.js
示例:SET UV_THREADPOOL_SIZE = 2 && node my-file-to-run.js