Websocket best practice for groups chat / one websocket for all groups or one websocket per group?

I think second approach will be better to use for performance. I am using the same for my application, but it is still in testing phase so can't comment about the real time performance. Now its running for 10-15 groups and working fine. In my app, there is similar condition like you in which user can chat based on group. I am handling the the group creation on server side using node.js. Here is the code to create group, but it is for my app specific condition. Just pasting here for the reference. Getting homeState and userId from front-end. Creating group based on the homeState. This code is only for example, it won't work for you. To improve performance you can use clustering.

this.ConnectionObject = function(homeState, userId, ws) {
            this.homeState = homeState;
            this.userId = userId;
            this.wsConnection = ws;
        },

        this.createConnectionEntry = function(homeState, userId,
                ws) {

            var connObject = new ws.thisRefer.ConnectionObject(homeState, userId,
                    ws);
            var connectionEntryList = null;
            if (ws.thisRefer.connectionMap[homeState] != undefined) {
                connectionEntryList = ws.thisRefer.connectionMap[homeState];
            } else {
                connectionEntryList = new Array();
            }
            connectionEntryList.push(connObject);

            console.log(connectionEntryList.length);

            ws.thisRefer.connectionMap[homeState] = connectionEntryList;
            ws.thisRefer.connecteduserIdMap[userId]  = "";

        }