Pipe Media across nodes/k8s pods.

Hi Team, I am trying to deploy my Mediasoup server in Kubernetes cluster as pods. When I check for the scalability, most of the posts suggested to go for IPC (Inter Process Communication) with Redis pub/sub. In IPC architecture, users of same room can join in different WebSocket/Broker server, but their mediasoup resources stays in the same node for communication, garbage collection, recording etc.

Like roomA → Node A and roomB → Node B, roomC → Node A etc… This is mostly like room-based scaling across nodes/pods.

But I just want to know, if there is any way to scale mediasoup servers with round robin fashion of users like userA connected to nodeA and userB connected to nodeB, etc. In this case how users communicate with each other. I saw the implementation pipeToTransport() function. But seems like it is only useful when there are more than 500 producers/consumers created with same router. In that case extra router will be created, and it pipe the transport to second router2.

Is there is any way to load balance the users in Round Rabin and still achieve the entire functionality of Mediasoup? If yes, how mediasoup routers communicate with each other? how to remove Mediasoup resources in different nodes when call gets over?

Thanks for the help in advance.

I have done some work on mediasoup, if you want I can work with you on it contact me

Thanks for your reply. “Contact me” on the above message is not clickable.

Sorry about that, can you try again, I fixed it

Thanks. I have sent an email to you.

Can anyone suggest some solution for my above question?

Hi there,

To understand how to achieve load balancing with Mediasoup servers, it’s important to grasp a few key concepts:

  1. Media Hubs (Routers): Each user needs to connect to a router (or worker) to send and receive media. Think of this router as your media hub, where all media streams are managed (relayed).

  2. Connection to Media Hub: Without other means (such as FFmpeg or GStreamer), users must connect to the media hub to consume media from other producers or produce media for others to consume.

  3. Using Pipe Transports: When dealing with multiple servers (IPs), Mediasoup utilizes pipe transports to send media between different media hubs.

  4. Load Balancing and Pipe Transports: While load balancing can distribute users randomly across different servers, each user can only access media streams from other users on the same server unless pipe transports are used to make media produced in any server available for consumption in other servers.

To enable cross-server media consumption, implementing pipe transports is essential. This allows media produced on one server to be accessible for consumption on other servers, ensuring seamless communication across your Mediasoup infrastructure.