Workers, clusters and memory

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

  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.

Thanks for the reply.

    • The question was where to store routers (room instances with the router as a property) not workers :slight_smile:

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.