# createPipeTransport , PipeTransport

**URL:** <https://mediasoup.discourse.group/t/createpipetransport-pipetransport/5162>\
**Category:** mediasoup libraries\
**Created:** [April 16, 2023, 11:22am UTC](https://mediasoup.discourse.group/t/createpipetransport-pipetransport/5162 "2023-04-16T11:22:36Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![robokishan](https://avatars.discourse-cdn.com/v4/letter/r/ea666f/32.png) [@robokishan](https://mediasoup.discourse.group/u/robokishan)\
**Post date:** [April 16, 2023, 11:22am UTC](https://mediasoup.discourse.group/t/createpipetransport-pipetransport/5162/1 "2023-04-16T11:22:36Z")

</div>

I read [mediasoup/Router.ts at 6c9a9424352d5504f9b1f7acbd077f6be9368d7a · versatica/mediasoup · GitHub](https://github.com/versatica/mediasoup/blob/6c9a9424352d5504f9b1f7acbd077f6be9368d7a/node/src/Router.ts#L749) to implement createPipeTransport between two media soup worker nodes.  
I see that pipeRouter is using previously created pipeTransport for piping.  
Does that mean we can share pipe transport between multiple users and avoid creating duplicate transport between two workers?  
Duplicate Pipe Transport means Let’s say i have User A, B, C , D in Worker 1 and W, X , Y, Z in Worker 2 for Room 1. Right now i am creating piping for all these users between two workers. that means piping for A-W, A-X, A-Y, A-Z , B-W and so on… because that is what written in the documentation. But i want to improve that and i was hoping for some solutions.

Is it possible to use createPipeTransport between two worker only once and then we can share it for multiple producers and consumers ?

---

<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 16, 2023, 12:59pm UTC](https://mediasoup.discourse.group/t/createpipetransport-pipetransport/5162/2 "2023-04-16T12:59:39Z")

</div>

> [@robokishan](#):
>
> A-W, A-X, A-Y, A-Z , B-W and so on

This is not the right way, to share a producer\_1 from worker\_1 to worker\_2 you will use only one pipe transport and after that producer\_1 will also be available in worker\_2 and then you can consume it multiple time from worker\_2 just like normal way.

So if user W, X, Y, Z from worker\_2 want to consumer producer\_1 from worker\_1 then use one pipe transport to pipe producer\_1 to worker\_2 and let user W, X, Y, Z consume the piped producer after that.

Piping is the process of piping a producer from one router to another router. Forget about the users which you just mentioned and just use one pipe transport to produce one producer from router 1 to router 2 this is it.

---

<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 16, 2023, 1:06pm UTC](https://mediasoup.discourse.group/t/createpipetransport-pipetransport/5162/3 "2023-04-16T13:06:43Z")

</div>

> [@robokishan](#):
>
> Is it possible to use createPipeTransport between two worker only once and then we can share it for multiple producers and consumers ?

About whether pipe transport allows multiple producers to be piped between workers, It should but I am not sure.

---

<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:** [April 16, 2023, 1:11pm UTC](https://mediasoup.discourse.group/t/createpipetransport-pipetransport/5162/4 "2023-04-16T13:11:52Z")

</div>

1. Create a PipeTransport1 in worker1.
2. Créate a PipeTransport2 in worker2.
3. Produce and consume as much as you want in PipeTransport1 and PipeTransport2.

---

<div class="post-metadata">

**Author:** ![robokishan](https://avatars.discourse-cdn.com/v4/letter/r/ea666f/32.png) [@robokishan](https://mediasoup.discourse.group/u/robokishan)\
**Post date:** [April 16, 2023, 1:44pm UTC](https://mediasoup.discourse.group/t/createpipetransport-pipetransport/5162/5 "2023-04-16T13:44:09Z")

</div>

Oh, That means i am just creating too many pipetransport. Thank you I will optimize this.  
Is there any drawback of having single pipetransport if too many users are connected does it lag or anything i should take care while writing the code ? since i didn’t find anything related to lag or conditions in doc.

Thank you

---

<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:** [April 16, 2023, 3:57pm UTC](https://mediasoup.discourse.group/t/createpipetransport-pipetransport/5162/6 "2023-04-16T15:57:27Z")

</div>

> [@robokishan](#):
>
> Is there any drawback of having single pipetransport if too many users are connected does it lag or anything i should take care while writing the code ? since i didn’t find anything related to lag or conditions in doc.

Why should the docs say that something doesn’t produce lag if it doesn’t produce any lag?

---

<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 16, 2023, 4:43pm UTC](https://mediasoup.discourse.group/t/createpipetransport-pipetransport/5162/7 "2023-04-16T16:43:55Z")

</div>

There is no problem with single pipetransport if the workers are not going to reach the full capactity.

In general you will be needing multiple pipetransports in a call (meeting) to scale properly. You can’t just create one pipetransport between 2 workers and produce, consume unlimited time, because workers have their capacity limit as per cpu core capacity.

Lets say you have created pipetransport between worker\_1, worker\_2 and you have piped 2 producers from worker\_1 to worker\_2 now worker\_2 has reached around 98% of capacity.

So far so good but now you want to pipe one more producer from worker\_1 to worker\_2 in that case if you try to pipe one more producer to worker\_2 then worker\_2 will cross it’s capacity and can cause lagging issue which you have concerns about.

What you will do then?

You will consider using another worker worker\_3 and create another pipetransport between worker\_1 and worker\_3 and pipe the producer.
