# Recommended number of mediasoup-worker processes

**URL:** <https://mediasoup.discourse.group/t/recommended-number-of-mediasoup-worker-processes/1923>\
**Category:** mediasoup libraries\
**Created:** [October 24, 2020, 5:26am UTC](https://mediasoup.discourse.group/t/recommended-number-of-mediasoup-worker-processes/1923 "2020-10-24T05:26:55Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![mustafa](https://avatars.discourse-cdn.com/v4/letter/m/f19dbf/32.png) [@mustafa](https://mediasoup.discourse.group/u/mustafa)\
**Post date:** [October 24, 2020, 5:26am UTC](https://mediasoup.discourse.group/t/recommended-number-of-mediasoup-worker-processes/1923/1 "2020-10-24T05:26:55Z")

</div>

Hi,  
What is the recommended number of mediasoup-worker.exe processes for a 40 core CPU. And how many router can be opened in each process.

Thanks,

---

<div class="post-metadata">

**Author:** ![ibc](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/ibc/32/1540_2.png) [@ibc](https://mediasoup.discourse.group/u/ibc)\
**Post date:** [October 24, 2020, 10:57am UTC](https://mediasoup.discourse.group/t/recommended-number-of-mediasoup-worker-processes/1923/2 "2020-10-24T10:57:41Z")

</div>

> [@mustafa](#):
>
> What is the recommended number of mediasoup-worker.exe processes for a 40 core CPU

40

> [@mustafa](#):
>
> And how many router can be opened in each process.

Wrong question. This is not about number of routers.

---

<div class="post-metadata">

**Author:** ![mustafa](https://avatars.discourse-cdn.com/v4/letter/m/f19dbf/32.png) [@mustafa](https://mediasoup.discourse.group/u/mustafa)\
**Post date:** [October 24, 2020, 11:37am UTC](https://mediasoup.discourse.group/t/recommended-number-of-mediasoup-worker-processes/1923/3 "2020-10-24T11:37:47Z")

</div>

What is the correct question, is it about number of transports in each router.

---

<div class="post-metadata">

**Author:** ![ibc](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/ibc/32/1540_2.png) [@ibc](https://mediasoup.discourse.group/u/ibc)\
**Post date:** [October 24, 2020, 11:53am UTC](https://mediasoup.discourse.group/t/recommended-number-of-mediasoup-worker-processes/1923/4 "2020-10-24T11:53:27Z")

</div>

There is no magic response to that question, sorry.

---

<div class="post-metadata">

**Author:** ![mustafa](https://avatars.discourse-cdn.com/v4/letter/m/f19dbf/32.png) [@mustafa](https://mediasoup.discourse.group/u/mustafa)\
**Post date:** [October 24, 2020, 12:19pm UTC](https://mediasoup.discourse.group/t/recommended-number-of-mediasoup-worker-processes/1923/5 "2020-10-24T12:19:38Z")

</div>

My main question that I couldn’t have any answer on it is how can I distribute users or rooms over servers in order to have a conference without any issue from server side. Is there any rule that I can follow I can give some numbers.  
We made a webinar application based on mediasoup for schools, and now we have more than 50k active users. we distributed the users on servers each with 2500 user and this number is based on the bandwidth that each server can handle with the specified maxbitrates and everything is working fine concerning the bandwidth capacity of each server. Concerning the CPU we open 40 worker on each 40 core server and distribute router in round robin across the workers and everything is working fine the CPU is not exceeding 30% at the peak time. We are also recording the webinar using FFmpeg and plain transports, also the CPU is not increasing more than 10%. Everything is fine. However, some users are experiencing some latency at specific times when creating producers, some others are facing problems in sound quality. I don’t know if these issues are network issues from client side or from mediasoup worker it self when it is handling more than one router at the same time with this number of user.  
From two months till now we made a great job using mediasoup but we are still experiencing these issues we don’t know if it is a limitation from mediasoup or not.  
At the same time each server is handling about 100 room each having about 25 users on average, each user has producing transport and consuming transport.  
Thanks,

---

<div class="post-metadata">

**Author:** ![copiltembel](https://avatars.discourse-cdn.com/v4/letter/c/e9a140/32.png) [@copiltembel](https://mediasoup.discourse.group/u/copiltembel)\
**Post date:** [October 24, 2020, 6:23pm UTC](https://mediasoup.discourse.group/t/recommended-number-of-mediasoup-worker-processes/1923/6 "2020-10-24T18:23:17Z")

</div>

I subscribe to the fact that there are is no magic answer to your question.

Moreover, my feeling is that you are contradicting yourself:

> [@mustafa](#):
>
> how can I distribute users or rooms over servers in order to have a conference without any issue from server side

> [@mustafa](#):
>
> I don’t know if these issues are network issues from client side or from mediasoup worker it self when it is handling more than one router at the same time with this number of user.

But since I don’t want to be all negative about your question:

> [@mustafa](#):
>
> However, some users are experiencing some latency at specific times when creating producers

Do you mean consumers? Since it’s a webinar I expect that you have one main producer and lots of consumers. Or is everyone supposed to see/hear everyone else?  
Usually, a keyframe is requested when a new consumer connects, which might be quite computationally intensive on the hardware and produce a bigger data packet to be sent over the network, which in turn might degrade the experience for some/all users. Did you go through [this page](https://mediasoup.org/documentation/v3/scalability)?

---

<div class="post-metadata">

**Author:** ![mustafa](https://avatars.discourse-cdn.com/v4/letter/m/f19dbf/32.png) [@mustafa](https://mediasoup.discourse.group/u/mustafa)\
**Post date:** [October 24, 2020, 7:04pm UTC](https://mediasoup.discourse.group/t/recommended-number-of-mediasoup-worker-processes/1923/7 "2020-10-24T19:04:04Z")

</div>

> [@copiltembel](#):
>
> Or is everyone supposed to see/hear everyone else

Yes this is my case, a room with a teacher that produces Audio, camera and screen share, and students that produces audio. In my case if there are 30 student in a room all hearing each other from there are more than 900 consumer in a router.

> [@copiltembel](#):
>
> Did you go through [this page](https://mediasoup.org/documentation/v3/scalability)

From the link here I’m exceeding the limitation of a router since it can handle ~500 consumer, is that right. What kind of issues I will have in this case, and how can I overcome it.  
One more thing the teacher can mute the audio for students which will pause the producer will this help in reducing the issues?

---

<div class="post-metadata">

**Author:** ![copiltembel](https://avatars.discourse-cdn.com/v4/letter/c/e9a140/32.png) [@copiltembel](https://mediasoup.discourse.group/u/copiltembel)\
**Post date:** [October 24, 2020, 7:25pm UTC](https://mediasoup.discourse.group/t/recommended-number-of-mediasoup-worker-processes/1923/8 "2020-10-24T19:25:03Z")

</div>

> [@mustafa](#):
>
> From the link here I’m exceeding the limitation of a router since it can handle ~500 consumer, is that right.

To me it’s obvious that 500 video consumers need more resources than 500 audio consumers.

I believe you are too focused on getting a definitive number that will work for your setup perfectly. But there is no such number, as already said.

Those numbers are good just to make an idea about what has been tried, but to me it’s clear that they need to be taken into account in some kind of context:

“Depending on the host CPU capabilities…”

Also, you should read the entire page, not get stuck on that single part.

---

<div class="post-metadata">

**Author:** ![mustafa](https://avatars.discourse-cdn.com/v4/letter/m/f19dbf/32.png) [@mustafa](https://mediasoup.discourse.group/u/mustafa)\
**Post date:** [October 24, 2020, 7:37pm UTC](https://mediasoup.discourse.group/t/recommended-number-of-mediasoup-worker-processes/1923/9 "2020-10-24T19:37:04Z")

</div>

Thank you, do you recommend any testing tool in order to make my tests on the platform and monitor the performance based on the number of consumers.

---

<div class="post-metadata">

**Author:** ![ibc](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/ibc/32/1540_2.png) [@ibc](https://mediasoup.discourse.group/u/ibc)\
**Post date:** [October 24, 2020, 8:06pm UTC](https://mediasoup.discourse.group/t/recommended-number-of-mediasoup-worker-processes/1923/10 "2020-10-24T20:06:48Z")

</div>

What I recommend is to not send 30 audio streams to every user, and just allow to speak a few of them at the same time. No magic solution for this, it’s up to your application logic.

---

<div class="post-metadata">

**Author:** ![mustafa](https://avatars.discourse-cdn.com/v4/letter/m/f19dbf/32.png) [@mustafa](https://mediasoup.discourse.group/u/mustafa)\
**Post date:** [October 24, 2020, 8:08pm UTC](https://mediasoup.discourse.group/t/recommended-number-of-mediasoup-worker-processes/1923/11 "2020-10-24T20:08:45Z")

</div>

> [@ibc](#):
>
> What I recommend is to not send 30 audio streams to every user

Will the producer.pause help? ِAllowing audio for students is controlled by the teacher. Whenever the teacher allows audio for a specific student a producer is created and consumers to other students and teacher. Sometimes the teacher allows audio for all students at a time which means producers and consumers are created for all. What I’m thinking is to pause the producers unless an audio threshold is exceeded then a stream will be sent. Will this help?

---

<div class="post-metadata">

**Author:** ![zaidiqbal](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/zaidiqbal/32/1498_2.png) [@zaidiqbal](https://mediasoup.discourse.group/u/zaidiqbal)\
**Post date:** [May 29, 2022, 1:07pm UTC](https://mediasoup.discourse.group/t/recommended-number-of-mediasoup-worker-processes/1923/12 "2022-05-29T13:07:19Z")

</div>

I have asked same type of question here about max number of consumers per worker, this will help:

> [@Maximum number of consumers per worker is 500 w.r.t CPU?](https://mediasoup.discourse.group/t/maximum-number-of-consumers-per-worker-is-500-w-r-t-cpu/4058):
>
> It is mentioned in the official docs here: [mediasoup :: Scalability](https://mediasoup.org/documentation/v3/scalability/) and in discourse topic as well here: [A room with 100 participants](https://mediasoup.discourse.group/t/a-room-with-100-participants/1092) Does this mean that there is hard limit of 500 for a worker or does this mean that if I use high end server then the same worker can handle more than 500 consumers? I am using AWS instance g4dn.8xlarge which is a high end server and it has 32 cores. I am using 1 worker per call so each call has it’s own worker. I am showing max 20 streams to each participant so…

---

<div class="post-metadata">

**Author:** ![zaidiqbal](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/zaidiqbal/32/1498_2.png) [@zaidiqbal](https://mediasoup.discourse.group/u/zaidiqbal)\
**Post date:** [May 29, 2022, 1:44pm UTC](https://mediasoup.discourse.group/t/recommended-number-of-mediasoup-worker-processes/1923/13 "2022-05-29T13:44:06Z")

</div>

> [@mustafa](#):
>
> We made a webinar application based on mediasoup for schools, and now we have more than 50k active users. we distributed the users on servers each with 2500 user and this number is based on the bandwidth that each server can handle with the specified maxbitrates and everything is working fine concerning the bandwidth capacity of each server. Concerning the CPU we open 40 worker on each 40 core server and distribute router in round robin across the workers and everything is working fine the CPU is not exceeding 30% at the peak time.

@mustafa **how you managed to distribute users on different servers (machines)?**  
Before a call is started do you check between the servers to see which one is free then run that call on that server? Or you are piping media between different machines? Or you are doing something else?
