I am using Node.js to implement a Websocket client that subscribes to datafeed from multiple Websocket servers.
foo = new WebSocket('ws://foo.host ...')
bar = new WebSocket('ws://barhost ...')
baz = new WebSocket('ws://baz.host ...')
qux = new WebSocket('ws://qux.host ...')
foo.on('data', data => doSomething(data)) // 5 events per second
bar.on('data', data => doSomething(data)) // 1 events per second
baz.on('data', data => doSomething(data)) // 1 events per second
qux.on('data', data => doSomething(data)) // 1 events per second
Question: If we have a multi-core system (eg. 4 cores), is it possible to make use of Node.js Cluster to load balance the processing of the incoming Websocket data, such that each core will approximately receive 2 events per second to be handled?
Or is it better to manually start 8 node.js instances and pass it an argument [foo|bar|baz|qux] for selecting the Websocket server it will connect to?