# 1 receiver transport per client or 1 receiver transport per stream

**URL:** <https://mediasoup.discourse.group/t/1-receiver-transport-per-client-or-1-receiver-transport-per-stream/4019>\
**Category:** mediasoup libraries\
**Created:** [March 12, 2022, 1:07pm UTC](https://mediasoup.discourse.group/t/1-receiver-transport-per-client-or-1-receiver-transport-per-stream/4019 "2022-03-12T13:07:17Z")\
**Posts on this page:** 14\
**Page:** 1

<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:** [March 12, 2022, 1:07pm UTC](https://mediasoup.discourse.group/t/1-receiver-transport-per-client-or-1-receiver-transport-per-stream/4019/1 "2022-03-12T13:07:17Z")

</div>

I am testing an application where I am creating only 1 receiver transport on client side, and using that 1 receiver transport to consume multiple streams being produced. So on client side there is only 1 receiver transport and on server side there are n transports where n is number of participants.

**The things is by doing this way there is a video lag on all streams not a little but big one.**

Then to find the cause of this I spent 2-3 days but couldn’t find anything then eventually I tried the other approach which is 1 receiver transport per stream. **The results were amazing there was not lag in video streams I tested it for 2 hours, there was no issue.**

So apparently it seems 1 receiver transport, which is a peer connection, doesn’t handle 10-20 streams very well, may be it is ok to have 4-5 streams but 10-20 were causing lots of issues.

**This thing even happens on the demo mentioned in docs, because it is using 1 receiver on client side:**

> **[GitHub - versatica/mediasoup-demo: mediasoup official demo application](https://github.com/versatica/mediasoup-demo)**
>
> mediasoup official demo application. Contribute to versatica/mediasoup-demo development by creating an account on GitHub.

**Can someone confirm that this is the case?**

**Why 1 receiver can’t handle 10-20 streams on client side? Theoretically one peer connection should handle this number of streams as there is no limit mentioned by webrtc.**

---

<div class="post-metadata">

**Author:** ![BronzedBroth](https://avatars.discourse-cdn.com/v4/letter/b/ad7895/32.png) [@BronzedBroth](https://mediasoup.discourse.group/u/BronzedBroth)\
**Post date:** [March 12, 2022, 9:08pm UTC](https://mediasoup.discourse.group/t/1-receiver-transport-per-client-or-1-receiver-transport-per-stream/4019/2 "2022-03-12T21:08:26Z")

</div>

I’ll tell you it’s much better to have many peer-connections opened, one for your broadcast and each person you view. This allows you to have n-amount of servers handling the users. I’d never favor a single connection or that way of thinking as if one server goes down there goes the whole nest.

As for 10-20 streams, we’re talking higher demands that could be high for CPU/bandwidth; surely watch that as the worker uses a single core (or parts of it) so you could be maxing out the core/worker. 🙂

---

<div class="post-metadata">

**Author:** ![nazar-pc](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/nazar-pc/32/369_2.png) [@nazar-pc](https://mediasoup.discourse.group/u/nazar-pc)\
**Post date:** [March 13, 2022, 1:58am UTC](https://mediasoup.discourse.group/t/1-receiver-transport-per-client-or-1-receiver-transport-per-stream/4019/3 "2022-03-13T01:58:10Z")

</div>

Depends on architecture. It is generally much better to have one connection, so you can benefit from meaningful priorities between different streams in case there is a congestion.

---

<div class="post-metadata">

**Author:** ![snnz](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/snnz/32/693_2.png) [@snnz](https://mediasoup.discourse.group/u/snnz)\
**Post date:** [March 13, 2022, 6:40am UTC](https://mediasoup.discourse.group/t/1-receiver-transport-per-client-or-1-receiver-transport-per-stream/4019/4 "2022-03-13T06:40:21Z")

</div>

One connection or many, it all goes through the same client network interface, so there shouldn’t be much difference. This sounds more like an artifitial limitation on the number of packets per UDP port somewhere.

---

<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:** [March 13, 2022, 9:14am UTC](https://mediasoup.discourse.group/t/1-receiver-transport-per-client-or-1-receiver-transport-per-stream/4019/5 "2022-03-13T09:14:25Z")

</div>

n-amount of servers? I mean whether I open 1 receiver per client of 1 receiver per stream they will be on a single worker in most cases in a single call. Also cpu/core usage is not an issue at my side as I have very high end server and cpu mostly stays at 1% with 15 participants. Something else is causing the issue.

---

<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:** [March 13, 2022, 9:17am UTC](https://mediasoup.discourse.group/t/1-receiver-transport-per-client-or-1-receiver-transport-per-stream/4019/6 "2022-03-13T09:17:03Z")

</div>

Theoretically this seems right to me but somehow streams get disturbed when there is 1 receiver per client but works well if there is 1 receiver per stream. May be the point @snnz mentioned about limitations on number of packets per UDP port is the issue, what do you say?

You can test it on the mediasoup3 demo with around 10-15 people you will see the issue.

---

<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:** [March 13, 2022, 9:19am UTC](https://mediasoup.discourse.group/t/1-receiver-transport-per-client-or-1-receiver-transport-per-stream/4019/7 "2022-03-13T09:19:56Z")

</div>

Yes you are right it shouldn’t cause the issue. I will check packets per port to see if this is causing the issue, thanks

---

<div class="post-metadata">

**Author:** ![BronzedBroth](https://avatars.discourse-cdn.com/v4/letter/b/ad7895/32.png) [@BronzedBroth](https://mediasoup.discourse.group/u/BronzedBroth)\
**Post date:** [March 13, 2022, 10:14am UTC](https://mediasoup.discourse.group/t/1-receiver-transport-per-client-or-1-receiver-transport-per-stream/4019/8 "2022-03-13T10:14:46Z")

</div>

**Also cpu/core usage is not an issue at my side as I have very high end server and cpu mostly stays at 1% with 15 participants. Something else is causing the issue.**

If you think so, sure. Must be better than all of our servers. Double check your results.

---

<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:** [March 13, 2022, 11:00am UTC](https://mediasoup.discourse.group/t/1-receiver-transport-per-client-or-1-receiver-transport-per-stream/4019/9 "2022-03-13T11:00:42Z")

</div>

For the CPU part I am sure, the stats I shared with you are correct, it is a 32 core AWS instance.

---

<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:** [March 26, 2022, 7:31am UTC](https://mediasoup.discourse.group/t/1-receiver-transport-per-client-or-1-receiver-transport-per-stream/4019/10 "2022-03-26T07:31:56Z")

</div>

**I am answering here to my own question:**  
After experimenting on it for around a week the final conclusion is that using 1 receiver transport per client causes video lag and after few minutes leads to streams being ended especially on average network and by average I mean 10-15 mbps.

**The solution is to use 1 receiver transport per stream or 1 receiver transport for 2-5 streams may be** e.g I use 1 receiver transport per remote person in call, 1 remote person’s camera stream and screen stream both are consumed on that 1 receiver transport. This gives best results.

**These are the configuration on which I tested all of this:**

**Persons in call: 5**

**Client side:**  
network: 15mbps  
ram: 16gb  
cpu: i5, 4 cores

**Server side:**  
cpu: high end aws instance, 32 core  
ram: 150gb  
network: in gbs

---

<div class="post-metadata">

**Author:** ![ishan501](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/ishan501/32/1530_2.png) [@ishan501](https://mediasoup.discourse.group/u/ishan501)\
**Post date:** [April 11, 2022, 12:40pm UTC](https://mediasoup.discourse.group/t/1-receiver-transport-per-client-or-1-receiver-transport-per-stream/4019/11 "2022-04-11T12:40:13Z")

</div>

Hi, @zaidiqbal I’m trying to achieve what you have done. Can you please check my comments on your similar thread?  
[https://github.com/jamalag/mediasoup3/issues/1](https://github.com/jamalag/mediasoup3/issues/1)

---

<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:** [April 12, 2022, 6:07am UTC](https://mediasoup.discourse.group/t/1-receiver-transport-per-client-or-1-receiver-transport-per-stream/4019/12 "2022-04-12T06:07:41Z")

</div>

Responded, you are on right track with **1 consumer per client** approach.

---

<div class="post-metadata">

**Author:** ![ishan501](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/ishan501/32/1530_2.png) [@ishan501](https://mediasoup.discourse.group/u/ishan501)\
**Post date:** [April 12, 2022, 6:30am UTC](https://mediasoup.discourse.group/t/1-receiver-transport-per-client-or-1-receiver-transport-per-stream/4019/13 "2022-04-12T06:30:51Z")

</div>

Ok, thanks.

---

<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:** [April 13, 2022, 8:37am UTC](https://mediasoup.discourse.group/t/1-receiver-transport-per-client-or-1-receiver-transport-per-stream/4019/14 "2022-04-13T08:37:28Z")

</div>

It is **1 consumer per participant** or **1 consumer per stream** not **1 consumer per client**
