# Workers, clusters and memory

**URL:** <https://mediasoup.discourse.group/t/workers-clusters-and-memory/46>\
**Category:** mediasoup libraries\
**Created:** [May 31, 2019, 11:31pm UTC](https://mediasoup.discourse.group/t/workers-clusters-and-memory/46 "2019-05-31T23:31:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![renozzz](https://avatars.discourse-cdn.com/v4/letter/r/b19c9b/32.png) [@renozzz](https://mediasoup.discourse.group/u/renozzz)\
**Post date:** [May 31, 2019, 11:31pm UTC](https://mediasoup.discourse.group/t/workers-clusters-and-memory/46/1 "2019-05-31T23:31:03Z")

</div>

Hi there

I’ve been gathering information on how to properly setup a mediasoup server. I have a couple of questions:

1. According to the docs, mediasoup workers run on a single thread. In respect to Nodejs, how do the workers get forked to utilise multiple cores ?

2. What’s the best way to store routers ? Redis might not work here, since router objects might not be serialisable. Is memory shared between mediasoup workers ?

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:** [May 31, 2019, 11:52pm UTC](https://mediasoup.discourse.group/t/workers-clusters-and-memory/46/2 "2019-05-31T23:52:12Z")

</div>

1. The mediasoup JS launches a mediasoup-worker subprocess per Worker (JS) instance created via createWorker().

2. You cannot “store” a worker. You just deal with the Worker.js instance which is a common JavaScript class instance. You handle it in Node as any other object.

There is no shared memory. The Worker.js and it’s mediasoup-worker subprocess communicate one to each other via JSON message over UnixSocket. That’s internal stuff anyway you must not care about.

---

<div class="post-metadata">

**Author:** ![renozzz](https://avatars.discourse-cdn.com/v4/letter/r/b19c9b/32.png) [@renozzz](https://mediasoup.discourse.group/u/renozzz)\
**Post date:** [May 31, 2019, 11:55pm UTC](https://mediasoup.discourse.group/t/workers-clusters-and-memory/46/3 "2019-05-31T23:55:31Z")

</div>

Thanks for the reply.

1. 
  - The question was where to store routers (room instances with the router as a property) not workers 🙂

---

<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:** [June 1, 2019, 5:55am UTC](https://mediasoup.discourse.group/t/workers-clusters-and-memory/46/4 "2019-06-01T05:55:55Z")

</div>

Same response:

You just deal with the Router.js instance which is a common JavaScript class instance. You handle it in Node as any other object.

---

<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:** [December 2, 2019, 11:10pm UTC](https://mediasoup.discourse.group/t/workers-clusters-and-memory/46/5 "2019-12-02T23:10:47Z")

</div>


