Node.js cluster supports two scheduling policies: SCHED_RR (Round-Robin), where the master distributes connections evenly, and SCHED_NONE, where the OS decides which worker handles each connection. You configure this via cluster.schedulingPolicy.
The scheduling policy determines how incoming connections are distributed to worker processes. Round-Robin (SCHED_RR) is the default on Linux and macOS and provides more even distribution. SCHED_NONE leaves it to the OS, which can sometimes cause uneven load distribution but reduces master-process overhead.
Default on Linux and macOS
Master process assigns connections to workers one-by-one in a cycle
Provides more even and predictable load distribution
Master handles distribution logic — adds slight overhead to master
Default on Windows
Operating system decides which worker process accepts each connection
Can lead to uneven distribution — some workers may get overloaded
Lower overhead on the master process
You need to spawn four workers for a simple API using Node.js cluster. How would you configure the cluster to use the OS scheduler instead of the default round‑robin?
If you start a cluster without setting any scheduling policy, what load‑balancing behavior should you expect on Linux versus Windows?
What code changes are required to switch from round‑robin to the OS scheduler in a small script?
Your service shows uneven request distribution after adding a CPU‑intensive endpoint. How would you determine if the cluster's load‑balancing strategy is the cause, and what would you change?
During a deployment you notice some workers idle while others are overloaded. Explain how you would reconfigure the cluster's scheduling policy to address this and what trade‑offs you consider.
You need to support both Windows and Linux environments. How would you write code that selects the appropriate scheduling policy at runtime?
With 32 CPU cores handling a mix of I/O‑bound and CPU‑bound requests, discuss the pros and cons of round‑robin versus OS scheduling and how you would decide which to use for different parts of the system.
Monitoring shows latency spikes when the OS scheduler is used under high load. How would you redesign the cluster configuration or add custom load balancing to mitigate this?
Explain how you would implement a hybrid approach where certain routes use round‑robin and others rely on OS scheduling, and what challenges you might face.
Your organization is migrating a monolithic Node.js app to microservices and wants a standard for cluster load balancing across many services. What architectural guidelines would you set for choosing between round‑robin and OS scheduling, considering deployment pipelines, observability, and cross‑team maintenance?
A legacy service runs on Windows where the default is OS scheduling, but you want to adopt round‑robin for consistency. How would you plan the migration, handle configuration drift, and ensure minimal downtime?
Discuss the long‑term implications of hard‑coding a scheduling policy in shared libraries, and propose a strategy for making the choice configurable while preserving backward compatibility.