MediaSoup scalability

I want to ask about the scalability of MediaSoup. If I have a machine with 16 vCPUs and 32 Gb RAM, what is the maximum number of consumers it can handle, and how can I calculate the maximum number of consumers?

You need to put the load on the server to see the max number of consumer/producers in one worker/core. And do the rest of the calculations based upon that.

An average CPU can handle approx. 500 consumers/producers per worker. That is rough idea mentioned in the docs. It can vary on different machines.

So get the max consumers/producers per worker by putting load on server or go with 500 or may be 400 on safe side and then improve it later to have more close number as per your machine.

In our implementation, we use pipeToRouter method and it works like a charm. It’s not very easy, you need to figure out how to distribute the load depending on the type of your application.

There is a limit (500) for maximum number of connections per worker (cpu or core). So, in order to support much more viewers, you can use some workers just for publishers and you can use some workers just for viewers. Using pipeToRouter method, you can pipe a live stream to another router on the viewer workers. And then, you can distribute new consumers to routers on the viewer workers using a load balancing algorithm (e.g. round-robin).

There is a good discussion about mediasoup scalability where you can find here.

There is no limit from mediasoup, it depends upon the cpu capabilities. 500 is just a approx number mentioned in docs for the specific cpu on which the tests were conducted.

Yes I know. Thanks for the clarification.

More info: mediasoup :: Scalability

1 Like

I’ve been developing Mafalda SFU just with the purpose of provide transparent Mediasoup scalability, maybe you would be interested on it too.

Stop spamming, no body wants your Mafalda SFU. As for users serious about scaling, the weight system works best. If you want to go advanced you can sort from there what you need it’s flawless.

To define it quickly, a single worker may be able to handle 15 broadcasts at a time, so you limit server to 15 broadcasts but that’s assuming all broadcasts hit 100% usage when they combine their total powers.

Now not always will the 15 broadcasts use all of the service and so you can open further workers but we can low-prioritize them so if we need to clear all of a sudden space for a busy worker we can boot these users and find them a new server that has space for high-priority processing.

Fairly difficult stuff but if you can fathom you’re set bud.


Same process for consuming servers that fan the broadcast out to more users, we weigh these a bit differently but similar logic; difference is consumer would be setup to have maybe 12 weight, for every broadcast having 6 viewers we deduct a weight point. If 12 broadcasts we deduct 2 weight points so consumer server is at 10 weight. If the consumer server lacks weight to push a broadcast further a request to fan it further from there or have the broadcasting server transmit it to another server solves such It’s fancy stuff I don’t really got time to explain it so hopefully this helps.

I can’t give clear numbers cause we’re scaled all the way up and it can vary depending on amount of pipes and re-producing/etc.

For nobody caring about my “spammy” Mafalda SFU, you have gone really long trying to convince me why it’s useless and instead using weights are better than using Mafalda SFU without knowing how I’ve implemented It… I’m using actual CPU usage, so i can adjust and optimize number of streams in real time. Reading about your weights solution, i find It’s simple but also naïve, It underuse hardware resources, and needs to be manually adjusted. Can you explain me why is that better than a fully automomous and self managed solution like mine?

You’re just selling yourself, where is it exactly we see where to scale through your sources?

I offer my help for free and users will continue to see this, I have scaled and am capable of running infinite sizes as long as I grow my brokers. Now I may not describe my use-case properly but users have asked for details and I offer such. You can literally take my knowledge and run with it for free… where as you cost what?

Stop promoting I won’t buy and if you sell I’ll provide the service at half the price cause I run auto/managed and never have outages! Cheers.

Don’t buy it if you don’t want, nobody is forcing you :slight_smile:

1 Like

I wouldn’t, at least I’d offer a fraction of the cost.