Updated Architecture: Cluster Multi Process (markdown)

TJKoury 2016-10-20 17:44:14 -04:00
parent a4e7256786
commit fd62de8cbd
1 changed files with 7 additions and 5 deletions

@ -1,20 +1,22 @@
##Multi-Process Model
The multi-process version of Node-RED starts the admin server, interface, and API on the master process, then spawns workers that run the flows independently of the master process.
The multi-process version of Node-RED starts the admin server, interface, and API on the Master process, then spawns Workers that run the flows independently of the Master process.
Communication from the worker processes to the master is handled via IPC.
Communication from the Worker processes to the Master is handled via IPC.
##Files
| File | Description |
|:-----|:------------|
|clusterRED.js| In charge of general process management. Returns a 'clusterRED' object. Has methods to initialize master and worker processes, spawn and kill new processes, provide status on child processes. |
|clusterRED.js| In charge of general process management. Returns a 'clusterRED' object. Has methods to initialize master and Worker processes, spawn and kill new processes, provide status on child processes. |
|red.js| Controls instantiation of admin server, api , core admin UI, and static server.|
|red/runtime/events.js| Modification to the runtime event bus. Sends messages from Worker to Master, which are then broadcast to all other Workers. Messages from master are (marked)(https://github.com/TJKoury/node-red/blob/cluster/clusterRED.js#L134) so as not to cause a rebroadcast cascade.|
##Issues
- [ ] **Modified nodes**. As nodes are capable of binding ports, listening to file-system events, spawning other processes, etc., simply clustering by forking can lead to serious issues. There appear to be two options: modifying the nodes to play nice, or build in strict limitations on what nodes can do.
- [ ] **Config node capabilities**. Currently, config nodes (and certain nodes like TCP) are allowed to bind ports, meaning that if flows are loaded equally in the master and child processes, the master process will listen on that port, and then block the port from being [bound specifically to distribute incoming to workers](https://github.com/nodejs/node/blob/master/lib/cluster.js#L116). Some nodes might be run only in the master (inject) and [serve events to workers based on a round-robin approach](https://github.com/TJKoury/node-red/blob/cluster/clusterRED.js#L88). Limiting config nodes to run only on worker processes, then moving any code that could cause issues into a config node, could be a standardization solution to this issue.
- [ ] **Static server**. Run single-processed on master, or instantiate new static path on each clustered http-server instance? Does this option reside in the http-server config node menu, along with a static path?
- [ ] **Config node capabilities**. Currently, config nodes (and certain nodes like TCP) are allowed to bind ports, meaning that if flows are loaded equally in the Master and child processes, the Master process will listen on that port, and then block the port from being [bound specifically to distribute incoming to Workers](https://github.com/nodejs/node/blob/master/lib/cluster.js#L116). Some nodes might be run only in the Master (inject) and [serve events to Workers based on a round-robin approach](https://github.com/TJKoury/node-red/blob/cluster/clusterRED.js#L88). Limiting config nodes to run only on Worker processes, then moving any code that could cause issues into a config node, could be a standardization solution to this issue.
- [ ] **Static server**. Run single-processed on Master, or instantiate new static path on each clustered http-server instance? Does this option reside in the http-server config node menu, along with a static path?