Skip to content

socket.io chat example that will have cluster and rooms support

Notifications You must be signed in to change notification settings

m-garin/node.js-cluster-socket.io-rooms

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

node.js-cluster-socket.io-rooms

Made with

Node.js 6.9.2, socket.io 1.7.2, socket.io-redis 3.1.0, Redis 3.2.1

Useful

This is a useful feature to send notifications to a group of users (in rooms), or to a given user connected on several devices for example and take advantage of multi-core systems.

Features

Master manages connections, workers makes calculations.

Master fork workers (numCPUs-1) and listen events from client. When master accept new client connection - looking for an empty existing room or create new room (attach next room) in redis. If the room is more than (settings.needNumClientsToStartCalcRoom) people - start calculated on attached worker. When room on worker lifetime ends - worker destroy room and disconnect all clients from master.