You need to npm install the package socket.io-redis. Then start the server by command redis-server.
Add the following lines to your code.
var io = require('socket.io')(3000);
var redis = require('socket.io-redis');
io.adapter(redis({ host: 'localhost', port: 6379 }));
Then you need to modify your nginx configurations file to enable load balancing as in, http://socket.io/docs/using-multiple-nodes/#nginx-configuration
upstream io_nodes {
ip_hash;
server 127.0.0.1:6001;
server 127.0.0.1:6002;
server 127.0.0.1:6003;
server 127.0.0.1:6004;
}
Restart your nginx server and then run node server. This should scale your server too.