I have integrated the Mediasoup API into my own project and I was able to get multiple audio producers and consumers working on different devices with some hiccups, but it did work.
My current design integrates a “Room Manager” who is in charge of orchestrating the peers inside of a single “room”. When a router starts to get saturated, it requests another router from any of the workers that have the least load (currently my design allows for multiple routers within a single worker).
Currently, a “room” is made of many routers that interact with each other within a “Room Manager”.
I was reading the source code for https://dogehouse.tv and their implementation of mediasoup seemed so simple that it made me question if I was overcomplicating and over engineering my own solution.
Currently I have discovered the following 5 things and I want some feedback from someone who has already implemented mediasoup within their application.
In general, 1 peer will have 2 transports. 1 transport dedicated to sending and 1 transport dedicated to recieving. This peer will have 1 producer (if it chooses to produce audio) and N consumers (assuming listening is the default state of the app)
It is up to the application to keep track of the producers, consumers, transports, workers and routers and to release any references to these objects once they die.
It is better to have 1 router per worker, than N routers per worker.
Within these routers, you should designate 1 or 2 routers as “producer routers” the rest as “consumer routers” using
pipeToRouter. This will help to scale within a single machine.
If you want to scale horizontally, meaning having multiple SFU’s instantiated on N machines, you will have to have a signaling server to facilitate that conversation. This is something I am still confused about. Are we supposed to create another transport and start producing to the other voice server? Is it as simple as
pipeToRouterand changing the
listenIpto the remote ip? I don’t understand this part as much yet.
Thank you for your time and help to anyone who chooses to engage with this post.