If the room ID already exists, mainserver will send back the message to the client, including multicasting address and port number. Otherwise, mainserver will select a low load subserver, create the new chat room in it, then send back message to client. Subservers are responsible for creating a TCP connection with all their assigned chat clients. After receiving chat messages from clients, they will multicast the messages to specific group. They send messages to their specific subserver and receive messages by multicasting.
Client sends request message to mainserver.
In order to balance load, mainserver checks which subserver has the least load, according to the number of chat room. Then the mainserver will select the first one. If they both have one chat room, the mainserver can select randomly. We suppose that mainserver selected subserver1. Mainserver will send message to subserver1, telling it the multicasting group address and port number, and ask it to create a TCP socket, which is used to communicate with clients.