Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Actually your code should look like this:</p> <pre><code>var cluster = require('cluster'); var http = require('http'); var numCPUs = require('os').cpus().length; if (cluster.isMaster) { // Fork workers. for (var i = 0; i &lt; numCPUs; i++) { cluster.fork(); } } else { var sio = require('socket.io') , RedisStore = sio.RedisStore , io = sio.listen(8080, options); // Somehow pass this information to the workers io.set('store', new RedisStore); // Do the work here io.sockets.on('connection', function (socket) { socket.on('chat', function (data) { socket.broadcast.emit('chat', data); }) }); } </code></pre> <p>Another option is to open Socket.IO to listen on multiple ports and have something like HAProxy load-balance stuff. Anyway you know the most important thing: using RedisStore to scale outside a process!</p> <p>Resources:</p> <p><a href="http://nodejs.org/docs/latest/api/cluster.html" rel="nofollow noreferrer">http://nodejs.org/docs/latest/api/cluster.html</a> <br /> <a href="https://stackoverflow.com/questions/5944714/how-can-i-scale-socket-io">How can I scale socket.io?</a> <br /> <a href="https://stackoverflow.com/questions/5739357/how-to-reuse-redis-connection-in-socket-io">How to reuse redis connection in socket.io?</a> <br /> <a href="https://stackoverflow.com/questions/7972077/node-scale-socket-io-nowjs-scale-across-different-instances">Node: Scale socket.io / nowjs - scale across different instances</a> <br /> <a href="http://delicious.com/alessioaw/socket.io" rel="nofollow noreferrer">http://delicious.com/alessioaw/socket.io</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload