cluster.schedulingPolicy
调度策略,包括循环计数的 cluster.SCHED_RR
,以及由操作系统决定的 cluster.SCHED_NONE
。
这是一个全局设置,当第一个工作进程被衍生或者调用 .setupMaster()
时,都将第一时间生效。
除 Windows 外的所有操作系统中, SCHED_RR
都是默认设置。
只要 libuv 可以有效地分发 IOCP 句柄,而不会导致严重的性能冲击的话,Windows 系统也会更改为 SCHED_RR
。
cluster.schedulingPolicy
可以通过设置 NODE_CLUSTER_SCHED_POLICY
环境变量来实现。
这个环境变量的有效值包括 'rr'
和 'none'
。
The scheduling policy, either cluster.SCHED_RR
for round-robin or
cluster.SCHED_NONE
to leave it to the operating system. This is a
global setting and effectively frozen once either the first worker is spawned,
or .setupMaster()
is called, whichever comes first.
SCHED_RR
is the default on all operating systems except Windows.
Windows will change to SCHED_RR
once libuv is able to effectively
distribute IOCP handles without incurring a large performance hit.
cluster.schedulingPolicy
can also be set through the
NODE_CLUSTER_SCHED_POLICY
environment variable. Valid
values are 'rr'
and 'none'
.