Scalability in mediasoup example

I’ve been looking at the official demo, and I see that you decided to scale the server at the room-level only (i.e each room has a single worker and router assigned to it).

I’m testing mediasoup for fun, and in my case I want to try to make a single room with 200+ participants.
Thus, from what I understand, it’s better that this room will have multiple workers.

I just wanted to make sure that I correctly understood the concept.

  1. Is it a good idea to assign each newly connected peer a different worker (i.e similarly to getMediasoupWorker() in the example? The issue that I see here is complexity for handling multiple router communications (i.e each producer on each router will have router.pipeToRouter() to each other router?)

  2. Or maybe it is better to put all the producers on worker1, and each new consumer will consume from a different worker (i.e getMediasoupWorker()), then I’ll have to call router.pipeToRouter() from router1 on worker1 to router2…N on all other workers for each producers’s transport.

Hope that you can direct me to the better solution, thanks!


I also want to make a many to many call with a large capacity.

Assigning routers
One way to actually divide the would be to assign a new peer to a new router every time as you said. Though this way many routers will be almost unused and if there are several rooms they would then be using routers of other rooms. I don’t know if it’s recommended

What I would add is filling up the consumer workers until they reach the predefined max capacity before adding a new worker to the mesh. Although as a certain capacity of peers is reached, older connected peers must actually move their transport from the old router to the newly created one.
This way only the needed amount of routers is used and other routers are free.

In an example project I did find they assign the producer and consumer transports of a peer to the same router. And assign the peers to a new or least loaded router if the current router peer capacity is reached.piping newly created producer | getting current router or get a new one if limit reached

Needed routers
If we assume our routers can handle 500 consumers. And we have 200 peers with audio and video (2 consumers per peer). Then there would be about 80k consumers in total. This would bring the amount of routers necessary to 160 with 1.2 peers per router. 1.2 peers per router would be rounded to 1 assuming we have only 1 transport per peer which brings the total amount of routers needed to 200.

Max peers
With a limit of 500 consumers per router you could hold a maximum of 250 peers in this video call configuration. So to increase the amount of max users, the power of the cpu’s must increase, not only the amount.

client-side limitations
Every peer would also have 199*2 incoming data streams. This could cause some problems for the browser to handle so it would need a good simulcast or svc configuration to reduce quality or pause specific consumers.

I’m also asking myself if the amount of producers in worker1 also has a limit. As in the documentation only states about 500 consumers as limit (depending on the cpu load).

1 Like