Process clustering
Process clustering means that Node.js will create multiple copies of the same service in memory, preferably on separate CPU cores (all modern CPU's have more than a single core), and as tasks come in it will delegate that task to one of the copies; typically in a pattern called Round-Robin.
In Delphi or C/C++ we would approach this problem through multi-threading, and in some way that is what process clustering is. But there are some distinctions between these two techniques, because the clones that Node.js creates in memory are isolated processes in their own right, with their own process context (it's literally like staring the same program X amount of times). While we can debate the virtues of this way of doing things at length, provided to say - it works, and it works really well.
U |
Round-Robin |
Round-Robin is a scheduling algorithm, where the controller picks the next worker from a list of queue whenever a task must be dealt with; when it reaches the end of the list of queue, it simply starts from the beginning again - moving through the available workers in a circular fashion. If all the workers are busy the algorithm can spawn temporary workers to meet the demand (if allowed), or put the task on hold until a worker becomes available. Round-Robin is used in a variety of scenarios, from how operating systems deals with multi-tasking, to how JavaScript itself executes code behind the scenes. It is also common by server technology to keep track of threads and resources. Before we had multi-core CPU's, preemptive multi-tasking would use techniques like this to divide processor time between running programs. You can read more about this technique here: https://en.wikipedia.org/wiki/Round-robin_scheduling |