Colleagues, tell me how effective the nodejs module cluster is in your opinion, for example, I want to create a seamless world. How can I properly distribute the load on the processor? As a client-server connection, the socket.io library serves, raising a server on each core, I need to exchange between clients that are on different threads, we can organize this with the help of an IPC channel: from worker to master, from master to required to the worker However, the context switch takes some time, making a couple of tests found that the time is from 2-10ms. How effective is this approach in your opinion and how would you advise to organize an exchange?

const cluster = require('cluster'); const numCPUs = require('os').cpus().length; if (cluster.isMaster) { let start = new Array(9); let end = new Array(9); let workers = []; console.log(`Master ${process.pid} is running`); // Fork workers. for (let i = 0; i < 8; i++) { let worker = cluster.fork(); workers.push(worker); worker.on('message', (msg)=>{ end[worker.id] = new Date; console.log(`${worker.id} затратил время`, end[worker.id]-start[worker.id]); }); } // Дожидаемся запуска всех воркеров для более точного теста. setTimeout(()=>{ workers.forEach((work)=>{ start[work.id] = new Date; work.send('done'); }); },5000); cluster.on('exit', (worker, code, signal) => { console.log(`worker ${worker.process.pid} died`); }); } else { process.on('message', (msg) => { console.log('Мастер шлет сообщение',msg.length); process.send('done'); }); console.log(`Worker ${process.pid} started`); } 

    0