Erlang-Red: "The Conversation" [video]

@gregorius could I use erlang to manage multiple node processes? I was thinking about creating a pool of node processes managed and supervised by erlang. Would erlang load balance the tasks on each of these processes automatically? My goal is to use this pool of node processes to execute my node-red nodes in parallel.

Could you tell me if this architecture makes sense and if it is possible to do this with erlang? Thank you in advance

Good question and I've been thinking about this over the last couple of days and the answer is no. Why? Well because it - probably - becomes too confusing to have multiple processes representing the one and the same functionality.

Btw many nodes in Erlang-Red have in fact multiple processes but those are for management of their task - for example the exec node has a one process that sends updates to the frontend flow editor and one process that actually does the execution. Then there is another process for handling failure of the execution process. But for the user there is only one process.

One way of getting around this limitation is this kind of flow:

[{"id":"11d5e33de669cf2d","type":"group","z":"fc819ec4242345fc","style":{"stroke":"#999999","stroke-opacity":"1","fill":"none","fill-opacity":"1","label":true,"label-position":"nw","color":"#a4a4a4"},"nodes":["82badfccdb4fa58f","843034b53ab83b52","89b9a84d41c6fc09","313c6c6100e3c2cf","0a380b2b838b2dc1","97b6dc3721c65d7d","5a3caa3f9707d28c","ca0af663f75409bc","0d0687ae8a19d4b4","69be4e9defd4ca11","722ac8274ee49773","94edb8d8bc62845f","a3bea8aefadd1957","06d5398dde963bd0","2ec83e3b189096f3","53f325c80cf222c9","0503514ba94727f8","336151cd8b368588","9cb03d91ebf49678","9f84c386cefa18d2","1d2f67b441cdd4a2","16ca658c3d9f60a1","cd9ba147a12eab44","f755b7f3d34ffad0","9e1277970fab81da","c490074b09bcfc14","7d7f34775b417d33","65813917d79c6e9e","b112f9265ea6c723","7b80d55d46aee4c9","9c625f319a4de7e5","48cd2ea6df6abfcc","d04bee33648fcf2e","592a6ba3111fdaa2","fca7c53644f7d8f9","b10e5666b0e7298a","8ad36876237291bf","1b18e06026bf4048","cbe7f43c9d20c75d","ab92cf93c0f402fe","ed4ff1bfe9921eb1","4222d605e58e14de","b98bceb6c57aa069","e82217011cfa3ef0","0d053af47e339105","74679b984db0965e","480babc4dc038b44","f99cf75a642fb4f2","f87e1fc22e290cb3","84618213c3e1d459","92f282d58c5abff4","c684e183038d1e62","23ecb23e0b6258f1","df2dea7e16f66844","35abcb309339fe82","05dfeafebf6c305d","436a96ce1b6875e8","02adaae87988b714","f457aae1a199a9f9","e6a045bcad35f44e","a2687b19ff1b06e3","142a367af82a624e"],"x":2280.5709075927734,"y":549,"w":1382.5720100402832,"h":1218.3665551543236},{"id":"82badfccdb4fa58f","type":"switch","z":"fc819ec4242345fc","g":"11d5e33de669cf2d","name":"random router","property":"$random()","propertyType":"jsonata","rules":[{"t":"gt","v":"0.2","vt":"num"},{"t":"gt","v":"0.4","vt":"num"},{"t":"gt","v":"0.6","vt":"str"},{"t":"gt","v":"0.8","vt":"str"},{"t":"else"}],"checkall":"false","repair":false,"outputs":5,"x":2677.6661376953125,"y":1152,"wires":[["480babc4dc038b44"],["b10e5666b0e7298a"],["9e1277970fab81da"],["06d5398dde963bd0"],["843034b53ab83b52"]]},{"id":"843034b53ab83b52","type":"switch","z":"fc819ec4242345fc","g":"11d5e33de669cf2d","name":"content type check","property":"filename","propertyType":"msg","rules":[{"t":"regex","v":"[.]mp3$","vt":"str","case":true},{"t":"regex","v":"[.]mpeg$","vt":"str","case":true},{"t":"regex","v":"[.]m4a$","vt":"str","case":true},{"t":"regex","v":"[.]mp4$","vt":"str","case":true},{"t":"regex","v":"[.]png$","vt":"str","case":true},{"t":"cont","v":".svg","vt":"str"},{"t":"cont","v":".gif","vt":"str"},{"t":"cont","v":".jpg","vt":"str"},{"t":"cont","v":".jpeg","vt":"str"},{"t":"else"}],"checkall":"false","repair":false,"outputs":10,"x":2979.3331298828125,"y":1633.666748046875,"wires":[["89b9a84d41c6fc09"],["89b9a84d41c6fc09"],["313c6c6100e3c2cf"],["0a380b2b838b2dc1"],["97b6dc3721c65d7d"],["5a3caa3f9707d28c"],["ca0af663f75409bc"],["0d0687ae8a19d4b4"],["0d0687ae8a19d4b4"],["94edb8d8bc62845f"]]},{"id":"89b9a84d41c6fc09","type":"function","z":"fc819ec4242345fc","g":"11d5e33de669cf2d","name":"mp3","func":"msg.res._res.set(\"Content-Type\",\"audio/mpeg\")\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3186.8330078125,"y":1547.666748046875,"wires":[["722ac8274ee49773"]]},{"id":"313c6c6100e3c2cf","type":"function","z":"fc819ec4242345fc","g":"11d5e33de669cf2d","name":"m4a","func":"msg.res._res.set(\"Content-Type\",\"audio/x-m4a\")\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3186.8330078125,"y":1574.8334011501738,"wires":[["722ac8274ee49773"]]},{"id":"0a380b2b838b2dc1","type":"function","z":"fc819ec4242345fc","g":"11d5e33de669cf2d","name":"mp4","func":"msg.res._res.set(\"Content-Type\",\"video/mp4\")\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3186.8330078125,"y":1602.0000542534726,"wires":[["722ac8274ee49773"]]},{"id":"97b6dc3721c65d7d","type":"function","z":"fc819ec4242345fc","g":"11d5e33de669cf2d","name":"png","func":"msg.res._res.set(\"Content-Type\",\"image/png\")\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3186.8330078125,"y":1629.1667073567714,"wires":[["722ac8274ee49773"]]},{"id":"5a3caa3f9707d28c","type":"function","z":"fc819ec4242345fc","g":"11d5e33de669cf2d","name":"svg","func":"msg.res._res.set(\"Content-Type\",\"image/svg+xml\")\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3186.8330078125,"y":1656.3333604600703,"wires":[["722ac8274ee49773"]]},{"id":"ca0af663f75409bc","type":"function","z":"fc819ec4242345fc","g":"11d5e33de669cf2d","name":"gif","func":"msg.res._res.set(\"Content-Type\",\"image/gif\")\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3186.8330078125,"y":1683.500013563369,"wires":[["722ac8274ee49773"]]},{"id":"0d0687ae8a19d4b4","type":"function","z":"fc819ec4242345fc","g":"11d5e33de669cf2d","name":"jpeg","func":"msg.res._res.set(\"Content-Type\",\"image/jpeg\")\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3186.8330078125,"y":1710.6666666666674,"wires":[["722ac8274ee49773"]]},{"id":"69be4e9defd4ca11","type":"http in","z":"fc819ec4242345fc","g":"11d5e33de669cf2d","name":"","url":"/externalcontent/*","method":"get","upload":false,"swaggerDoc":"","x":2406.5709075927734,"y":1152.0954627990723,"wires":[["82badfccdb4fa58f"]]},{"id":"722ac8274ee49773","type":"file in","z":"fc819ec4242345fc","g":"11d5e33de669cf2d","name":"","filename":"filename","filenameType":"msg","format":"stream","chunk":false,"sendError":false,"encoding":"none","allProps":true,"x":3373.3331298828125,"y":1635.666748046875,"wires":[["142a367af82a624e"]]},{"id":"94edb8d8bc62845f","type":"junction","z":"fc819ec4242345fc","g":"11d5e33de669cf2d","x":3136.8330078125,"y":1741.3665551543236,"wires":[["a3bea8aefadd1957"]]},{"id":"a3bea8aefadd1957","type":"junction","z":"fc819ec4242345fc","g":"11d5e33de669cf2d","x":3236.8330078125,"y":1741.3665551543236,"wires":[["722ac8274ee49773"]]},{"id":"06d5398dde963bd0","type":"switch","z":"fc819ec4242345fc","g":"11d5e33de669cf2d","name":"content type check","property":"filename","propertyType":"msg","rules":[{"t":"regex","v":"[.]mp3$","vt":"str","case":true},{"t":"regex","v":"[.]mpeg$","vt":"str","case":true},{"t":"regex","v":"[.]m4a$","vt":"str","case":true},{"t":"regex","v":"[.]mp4$","vt":"str","case":true},{"t":"regex","v":"[.]png$","vt":"str","case":true},{"t":"cont","v":".svg","vt":"str"},{"t":"cont","v":".gif","vt":"str"},{"t":"cont","v":".jpg","vt":"str"},{"t":"cont","v":".jpeg","vt":"str"},{"t":"else"}],"checkall":"false","repair":false,"outputs":10,"x":2974.9993896484375,"y":1395,"wires":[["2ec83e3b189096f3"],["2ec83e3b189096f3"],["53f325c80cf222c9"],["0503514ba94727f8"],["336151cd8b368588"],["9cb03d91ebf49678"],["9f84c386cefa18d2"],["1d2f67b441cdd4a2"],["1d2f67b441cdd4a2"],["cd9ba147a12eab44"]]},{"id":"2ec83e3b189096f3","type":"function","z":"fc819ec4242345fc","g":"11d5e33de669cf2d","name":"mp3","func":"msg.res._res.set(\"Content-Type\",\"audio/mpeg\")\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3182.499267578125,"y":1309,"wires":[["16ca658c3d9f60a1"]]},{"id":"53f325c80cf222c9","type":"function","z":"fc819ec4242345fc","g":"11d5e33de669cf2d","name":"m4a","func":"msg.res._res.set(\"Content-Type\",\"audio/x-m4a\")\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3182.499267578125,"y":1336.1666531032988,"wires":[["16ca658c3d9f60a1"]]},{"id":"0503514ba94727f8","type":"function","z":"fc819ec4242345fc","g":"11d5e33de669cf2d","name":"mp4","func":"msg.res._res.set(\"Content-Type\",\"video/mp4\")\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3182.499267578125,"y":1363.3333062065976,"wires":[["16ca658c3d9f60a1"]]},{"id":"336151cd8b368588","type":"function","z":"fc819ec4242345fc","g":"11d5e33de669cf2d","name":"png","func":"msg.res._res.set(\"Content-Type\",\"image/png\")\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3182.499267578125,"y":1390.4999593098964,"wires":[["16ca658c3d9f60a1"]]},{"id":"9cb03d91ebf49678","type":"function","z":"fc819ec4242345fc","g":"11d5e33de669cf2d","name":"svg","func":"msg.res._res.set(\"Content-Type\",\"image/svg+xml\")\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3182.499267578125,"y":1417.6666124131953,"wires":[["16ca658c3d9f60a1"]]},{"id":"9f84c386cefa18d2","type":"function","z":"fc819ec4242345fc","g":"11d5e33de669cf2d","name":"gif","func":"msg.res._res.set(\"Content-Type\",\"image/gif\")\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3182.499267578125,"y":1444.833265516494,"wires":[["16ca658c3d9f60a1"]]},{"id":"1d2f67b441cdd4a2","type":"function","z":"fc819ec4242345fc","g":"11d5e33de669cf2d","name":"jpeg","func":"msg.res._res.set(\"Content-Type\",\"image/jpeg\")\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3182.499267578125,"y":1471.9999186197924,"wires":[["16ca658c3d9f60a1"]]},{"id":"16ca658c3d9f60a1","type":"file in","z":"fc819ec4242345fc","g":"11d5e33de669cf2d","name":"","filename":"filename","filenameType":"msg","format":"stream","chunk":false,"sendError":false,"encoding":"none","allProps":true,"x":3368.9993896484375,"y":1397,"wires":[["a2687b19ff1b06e3"]]},{"id":"cd9ba147a12eab44","type":"junction","z":"fc819ec4242345fc","g":"11d5e33de669cf2d","x":3132.499267578125,"y":1502.6998071074486,"wires":[["f755b7f3d34ffad0"]]},{"id":"f755b7f3d34ffad0","type":"junction","z":"fc819ec4242345fc","g":"11d5e33de669cf2d","x":3232.499267578125,"y":1502.6998071074486,"wires":[["16ca658c3d9f60a1"]]},{"id":"9e1277970fab81da","type":"switch","z":"fc819ec4242345fc","g":"11d5e33de669cf2d","name":"content type check","property":"filename","propertyType":"msg","rules":[{"t":"regex","v":"[.]mp3$","vt":"str","case":true},{"t":"regex","v":"[.]mpeg$","vt":"str","case":true},{"t":"regex","v":"[.]m4a$","vt":"str","case":true},{"t":"regex","v":"[.]mp4$","vt":"str","case":true},{"t":"regex","v":"[.]png$","vt":"str","case":true},{"t":"cont","v":".svg","vt":"str"},{"t":"cont","v":".gif","vt":"str"},{"t":"cont","v":".jpg","vt":"str"},{"t":"cont","v":".jpeg","vt":"str"},{"t":"else"}],"checkall":"false","repair":false,"outputs":10,"x":2972.9993896484375,"y":1152,"wires":[["c490074b09bcfc14"],["c490074b09bcfc14"],["7d7f34775b417d33"],["65813917d79c6e9e"],["b112f9265ea6c723"],["7b80d55d46aee4c9"],["9c625f319a4de7e5"],["48cd2ea6df6abfcc"],["48cd2ea6df6abfcc"],["592a6ba3111fdaa2"]]},{"id":"c490074b09bcfc14","type":"function","z":"fc819ec4242345fc","g":"11d5e33de669cf2d","name":"mp3","func":"msg.res._res.set(\"Content-Type\",\"audio/mpeg\")\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3180.499267578125,"y":1064,"wires":[["d04bee33648fcf2e"]]},{"id":"7d7f34775b417d33","type":"function","z":"fc819ec4242345fc","g":"11d5e33de669cf2d","name":"m4a","func":"msg.res._res.set(\"Content-Type\",\"audio/x-m4a\")\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3180.499267578125,"y":1091.1666531032988,"wires":[["d04bee33648fcf2e"]]},{"id":"65813917d79c6e9e","type":"function","z":"fc819ec4242345fc","g":"11d5e33de669cf2d","name":"mp4","func":"msg.res._res.set(\"Content-Type\",\"video/mp4\")\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3180.499267578125,"y":1118.3333062065976,"wires":[["d04bee33648fcf2e"]]},{"id":"b112f9265ea6c723","type":"function","z":"fc819ec4242345fc","g":"11d5e33de669cf2d","name":"png","func":"msg.res._res.set(\"Content-Type\",\"image/png\")\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3180.499267578125,"y":1145.4999593098964,"wires":[["d04bee33648fcf2e"]]},{"id":"7b80d55d46aee4c9","type":"function","z":"fc819ec4242345fc","g":"11d5e33de669cf2d","name":"svg","func":"msg.res._res.set(\"Content-Type\",\"image/svg+xml\")\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3180.499267578125,"y":1172.6666124131953,"wires":[["d04bee33648fcf2e"]]},{"id":"9c625f319a4de7e5","type":"function","z":"fc819ec4242345fc","g":"11d5e33de669cf2d","name":"gif","func":"msg.res._res.set(\"Content-Type\",\"image/gif\")\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3180.499267578125,"y":1199.833265516494,"wires":[["d04bee33648fcf2e"]]},{"id":"48cd2ea6df6abfcc","type":"function","z":"fc819ec4242345fc","g":"11d5e33de669cf2d","name":"jpeg","func":"msg.res._res.set(\"Content-Type\",\"image/jpeg\")\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3180.499267578125,"y":1226.9999186197924,"wires":[["d04bee33648fcf2e"]]},{"id":"d04bee33648fcf2e","type":"file in","z":"fc819ec4242345fc","g":"11d5e33de669cf2d","name":"","filename":"filename","filenameType":"msg","format":"stream","chunk":false,"sendError":false,"encoding":"none","allProps":true,"x":3366.9993896484375,"y":1145,"wires":[["e6a045bcad35f44e"]]},{"id":"592a6ba3111fdaa2","type":"junction","z":"fc819ec4242345fc","g":"11d5e33de669cf2d","x":3130.499267578125,"y":1257.6998071074486,"wires":[["fca7c53644f7d8f9"]]},{"id":"fca7c53644f7d8f9","type":"junction","z":"fc819ec4242345fc","g":"11d5e33de669cf2d","x":3230.499267578125,"y":1257.6998071074486,"wires":[["d04bee33648fcf2e"]]},{"id":"b10e5666b0e7298a","type":"switch","z":"fc819ec4242345fc","g":"11d5e33de669cf2d","name":"content type check","property":"filename","propertyType":"msg","rules":[{"t":"regex","v":"[.]mp3$","vt":"str","case":true},{"t":"regex","v":"[.]mpeg$","vt":"str","case":true},{"t":"regex","v":"[.]m4a$","vt":"str","case":true},{"t":"regex","v":"[.]mp4$","vt":"str","case":true},{"t":"regex","v":"[.]png$","vt":"str","case":true},{"t":"cont","v":".svg","vt":"str"},{"t":"cont","v":".gif","vt":"str"},{"t":"cont","v":".jpg","vt":"str"},{"t":"cont","v":".jpeg","vt":"str"},{"t":"else"}],"checkall":"false","repair":false,"outputs":10,"x":2969.9993896484375,"y":909,"wires":[["8ad36876237291bf"],["8ad36876237291bf"],["1b18e06026bf4048"],["cbe7f43c9d20c75d"],["ab92cf93c0f402fe"],["ed4ff1bfe9921eb1"],["4222d605e58e14de"],["b98bceb6c57aa069"],["b98bceb6c57aa069"],["0d053af47e339105"]]},{"id":"8ad36876237291bf","type":"function","z":"fc819ec4242345fc","g":"11d5e33de669cf2d","name":"mp3","func":"msg.res._res.set(\"Content-Type\",\"audio/mpeg\")\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3177.499267578125,"y":823,"wires":[["e82217011cfa3ef0"]]},{"id":"1b18e06026bf4048","type":"function","z":"fc819ec4242345fc","g":"11d5e33de669cf2d","name":"m4a","func":"msg.res._res.set(\"Content-Type\",\"audio/x-m4a\")\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3177.499267578125,"y":850.1666531032988,"wires":[["e82217011cfa3ef0"]]},{"id":"cbe7f43c9d20c75d","type":"function","z":"fc819ec4242345fc","g":"11d5e33de669cf2d","name":"mp4","func":"msg.res._res.set(\"Content-Type\",\"video/mp4\")\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3177.499267578125,"y":877.3333062065976,"wires":[["e82217011cfa3ef0"]]},{"id":"ab92cf93c0f402fe","type":"function","z":"fc819ec4242345fc","g":"11d5e33de669cf2d","name":"png","func":"msg.res._res.set(\"Content-Type\",\"image/png\")\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3177.499267578125,"y":904.4999593098964,"wires":[["e82217011cfa3ef0"]]},{"id":"ed4ff1bfe9921eb1","type":"function","z":"fc819ec4242345fc","g":"11d5e33de669cf2d","name":"svg","func":"msg.res._res.set(\"Content-Type\",\"image/svg+xml\")\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3177.499267578125,"y":931.6666124131953,"wires":[["e82217011cfa3ef0"]]},{"id":"4222d605e58e14de","type":"function","z":"fc819ec4242345fc","g":"11d5e33de669cf2d","name":"gif","func":"msg.res._res.set(\"Content-Type\",\"image/gif\")\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3177.499267578125,"y":958.8332655164941,"wires":[["e82217011cfa3ef0"]]},{"id":"b98bceb6c57aa069","type":"function","z":"fc819ec4242345fc","g":"11d5e33de669cf2d","name":"jpeg","func":"msg.res._res.set(\"Content-Type\",\"image/jpeg\")\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3177.499267578125,"y":985.9999186197924,"wires":[["e82217011cfa3ef0"]]},{"id":"e82217011cfa3ef0","type":"file in","z":"fc819ec4242345fc","g":"11d5e33de669cf2d","name":"","filename":"filename","filenameType":"msg","format":"stream","chunk":false,"sendError":false,"encoding":"none","allProps":true,"x":3363.9993896484375,"y":911,"wires":[["f457aae1a199a9f9"]]},{"id":"0d053af47e339105","type":"junction","z":"fc819ec4242345fc","g":"11d5e33de669cf2d","x":3127.499267578125,"y":1016.6998071074486,"wires":[["74679b984db0965e"]]},{"id":"74679b984db0965e","type":"junction","z":"fc819ec4242345fc","g":"11d5e33de669cf2d","x":3227.499267578125,"y":1016.6998071074486,"wires":[["e82217011cfa3ef0"]]},{"id":"480babc4dc038b44","type":"switch","z":"fc819ec4242345fc","g":"11d5e33de669cf2d","name":"content type check","property":"filename","propertyType":"msg","rules":[{"t":"regex","v":"[.]mp3$","vt":"str","case":true},{"t":"regex","v":"[.]mpeg$","vt":"str","case":true},{"t":"regex","v":"[.]m4a$","vt":"str","case":true},{"t":"regex","v":"[.]mp4$","vt":"str","case":true},{"t":"regex","v":"[.]png$","vt":"str","case":true},{"t":"cont","v":".svg","vt":"str"},{"t":"cont","v":".gif","vt":"str"},{"t":"cont","v":".jpg","vt":"str"},{"t":"cont","v":".jpeg","vt":"str"},{"t":"else"}],"checkall":"false","repair":false,"outputs":10,"x":2966.9993896484375,"y":676,"wires":[["f99cf75a642fb4f2"],["f99cf75a642fb4f2"],["f87e1fc22e290cb3"],["84618213c3e1d459"],["92f282d58c5abff4"],["c684e183038d1e62"],["23ecb23e0b6258f1"],["df2dea7e16f66844"],["df2dea7e16f66844"],["05dfeafebf6c305d"]]},{"id":"f99cf75a642fb4f2","type":"function","z":"fc819ec4242345fc","g":"11d5e33de669cf2d","name":"mp3","func":"msg.res._res.set(\"Content-Type\",\"audio/mpeg\")\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3174.499267578125,"y":590,"wires":[["35abcb309339fe82"]]},{"id":"f87e1fc22e290cb3","type":"function","z":"fc819ec4242345fc","g":"11d5e33de669cf2d","name":"m4a","func":"msg.res._res.set(\"Content-Type\",\"audio/x-m4a\")\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3174.499267578125,"y":617.1666531032988,"wires":[["35abcb309339fe82"]]},{"id":"84618213c3e1d459","type":"function","z":"fc819ec4242345fc","g":"11d5e33de669cf2d","name":"mp4","func":"msg.res._res.set(\"Content-Type\",\"video/mp4\")\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3174.499267578125,"y":644.3333062065976,"wires":[["35abcb309339fe82"]]},{"id":"92f282d58c5abff4","type":"function","z":"fc819ec4242345fc","g":"11d5e33de669cf2d","name":"png","func":"msg.res._res.set(\"Content-Type\",\"image/png\")\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3174.499267578125,"y":671.4999593098964,"wires":[["35abcb309339fe82"]]},{"id":"c684e183038d1e62","type":"function","z":"fc819ec4242345fc","g":"11d5e33de669cf2d","name":"svg","func":"msg.res._res.set(\"Content-Type\",\"image/svg+xml\")\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3174.499267578125,"y":698.6666124131953,"wires":[["35abcb309339fe82"]]},{"id":"23ecb23e0b6258f1","type":"function","z":"fc819ec4242345fc","g":"11d5e33de669cf2d","name":"gif","func":"msg.res._res.set(\"Content-Type\",\"image/gif\")\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3174.499267578125,"y":725.8332655164941,"wires":[["35abcb309339fe82"]]},{"id":"df2dea7e16f66844","type":"function","z":"fc819ec4242345fc","g":"11d5e33de669cf2d","name":"jpeg","func":"msg.res._res.set(\"Content-Type\",\"image/jpeg\")\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3174.499267578125,"y":752.9999186197924,"wires":[["35abcb309339fe82"]]},{"id":"35abcb309339fe82","type":"file in","z":"fc819ec4242345fc","g":"11d5e33de669cf2d","name":"","filename":"filename","filenameType":"msg","format":"stream","chunk":false,"sendError":false,"encoding":"none","allProps":true,"x":3360.9993896484375,"y":678,"wires":[["02adaae87988b714"]]},{"id":"05dfeafebf6c305d","type":"junction","z":"fc819ec4242345fc","g":"11d5e33de669cf2d","x":3124.499267578125,"y":783.6998071074486,"wires":[["436a96ce1b6875e8"]]},{"id":"436a96ce1b6875e8","type":"junction","z":"fc819ec4242345fc","g":"11d5e33de669cf2d","x":3224.499267578125,"y":783.6998071074486,"wires":[["35abcb309339fe82"]]},{"id":"02adaae87988b714","type":"http response","z":"fc819ec4242345fc","g":"11d5e33de669cf2d","name":"","statusCode":"","headers":{},"x":3587.1429176330566,"y":678,"wires":[]},{"id":"f457aae1a199a9f9","type":"http response","z":"fc819ec4242345fc","g":"11d5e33de669cf2d","name":"","statusCode":"","headers":{},"x":3587.1429176330566,"y":911,"wires":[]},{"id":"e6a045bcad35f44e","type":"http response","z":"fc819ec4242345fc","g":"11d5e33de669cf2d","name":"","statusCode":"","headers":{},"x":3587.1429176330566,"y":1145,"wires":[]},{"id":"a2687b19ff1b06e3","type":"http response","z":"fc819ec4242345fc","g":"11d5e33de669cf2d","name":"","statusCode":"","headers":{},"x":3587.1429176330566,"y":1397,"wires":[]},{"id":"142a367af82a624e","type":"http response","z":"fc819ec4242345fc","g":"11d5e33de669cf2d","name":"","statusCode":"","headers":{},"x":3587.1429176330566,"y":1635.666748046875,"wires":[]}]

What this does is create new processes for sending off data down the same http pipe. The read file node is duplicated so that any request that comes is spread across multiple processes. That flow is in fact my content delivery in Node-RED. In real life (not this version) it implements http chunking to make image/video downloads faster.

Important here is the duplication - I guess it could also be done using a subflow but Erlang-Red does support them yet.

Erlang is Turing complete so yes it is possible. Again, as I said yesterday, whether that is the best approach is a different question. I don't think it is because a) it's too much implementation b) can be done simpler using a Node-RED instance talking to a Erlang-Red, regardless of HTTP/MQTT/JSON overhead.

Again, I - personally - don't want to implement anything that takes weeks and weeks and then no one uses it. I would encourage you to also think a bit like that.

Now don't get me wrong, Erlang-Red is months and months of working and no one is using it. But that's a labour of love, that is something completely different :wink:

If building an architecture for executing JS code in Erlang is a labour of love for you, then do it. If big-tech came to me and asked me to create something where they could keep their existing collection of NodeJS nodes but use Erlang-Red, I would still use a MQTT bridge between the two, regardless of performance. Or rather which performance?

Performance in the sense of CPU cycles or wall-clock time? Building a bridge between the two will be faster than creating an NodeJS interpreter for Erlang-Red. That would lead to quicker insights into the approach overall rather than spending more time on implementation upfront.

1 Like

Thank you. I was just curious. I might try this experiment one day

1 Like

Also one thing that I haven't mentioned is message handling in Erlang. This is very important design decision that makes a flow like that possible in the first place.

Messages are sent between processes but what one has to understand is that messages are handled atomically by processes: one message is handled before handling any other messages. Each process has a queue and each message is handle serially: one after the other.

This means that process can have state that is changed atomically, in the order that messages are received. This is a great inbuilt feature that allows well defined state to exist in a parallel/concurrent system.

A second feature is that process can either send message synchronously to other process, i.e. waiting for a response from the receiver. This implies that the message queue of the receiver isn't full up because then the sender would wait longer - message queues are handled FIFO - first in, first out, or alternatively: last in, last out....

But a sender can also select to send messages asynchronously, it then does not block for a response from the receiver. This is how all messages between nodes are sent in Erlang-Red. Hence the flow above would work really well since no one is waiting for anything.

This is one of the central design decisions of Flow Based Programming ... hence it fits well with Erlang.

For many users in here it might be the same as for me; I'm really enjoying to read and hopefully understand, all credits and respect to you, the situation is however I already have everything in my home security & automation up running and done to perfection with NR (I think..).

Flows with very specific & dedicated tasks are distributed on....let's see now...9 headless computers of various kind that I rarely touch so my effort to migrate, well it would be a pretty heavy task. If I would have started from scratch or if I need to setup things for another home I will for sure consider. Thats just me, others may think differently of course

2 Likes

Thanks for saying that - warm fuzzy feeling for me! :hugs:

Also I don't expect anyone to start using Erlang-Red, I've come to realise that it is a very hard sell but that's not say that it would be sold! It's extremely niche product and that's fine, after all, if everyone would be doing this then I won't be working on it.

Erlang-Red, as I'm discovering, has a place in industry: there are companies that use Node-RED for some stuff but also have a cellar full of Erlang code. These companies would be interested in Erlang-Red as a way of making their Erlang code more accessible. It's not common but it's also not unknown.

As I said, I do it as a labour of love and because I'm learning a lot on Erlang and concurrent systems. Plus to see how far I can take FBP and provide an alternative to textual coding :wink:

2 Likes

Kind of get a slight whispering of that feeling. Reminds me, I think put all my heart & love into EventGhost for some ten years or so, writing plugins in Python (similar to nodes in ER & NR), shared them to others. Never got any other credit, just satisfaction, seeing some of them flying over the world used by thousands of users in all kind of far & closer locations (actually wrote the first plugin for MQTT already 2013 to allow the use and integration w mosquitto, hardly anybody knew at that time what it was. I notified Roger Light about it, remember he appreciated that I did it)

1 Like

BTW I even wrote a plugin for ActiveMQ, even fewer knew what that was :wink:

Howabout a bash shell script using sed & awk to create a wiki-wiki website on a Linksys WRT54G - that's also one reason I say: is it software? Well then it can solve your problem!

I did that back in the days when wiki.c2.com invented wikis and Linksys just got busted for using open source GPL software on their closed sourced firmware.

But Bash-Red (ok Tcsh-Red is better) isn't out of scope and since bash/shells have pipes, they already have the basis for FBP!