cluster.schedulingPolicy
调度策略,可以是用于轮询的 cluster.SCHED_RR,或留给操作系统处理的 cluster.SCHED_NONE。这是一个全局设置,一旦第一个工作进程启动,或者调用 .setupPrimary()(以先发生者为准),该设置就基本固定了。
【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 .setupPrimary() is called, whichever comes first.】
SCHED_RR 是除 Windows 外所有操作系统的默认设置。一旦 libuv 能够在不造成较大性能损失的情况下有效分配 IOCP 句柄,Windows 将切换到 SCHED_RR。
cluster.schedulingPolicy 也可以通过 NODE_CLUSTER_SCHED_POLICY 环境变量设置。有效值为 'rr' 和 'none'。