Simple demo of using socket io redis adapter for scaling sockets
npm install
- Run
PORT=3000 node index.js
from one terminal - Run
PORT=3001 node index.js
from another terminal - Open both urls in browser and try typing some message on both.
- You can see that messages are sent between those server processes and displayed on web page.
- Try to Remove
var redis = require('socket.io-redis');
io.adapter(redis({ host: 'localhost', port: 6379 }));
To see that in this case, the messages won't be sent to both server instances.