just a quick question regarding to the rust mediasoup, i see the approach in the example, it creates a new worker per router, is that the most efficiency way to do so in the rust mediasoup?
compare with the typescript version there are differences, as the typescript version we would create workers per our cpu cores, then randomly use worker on creation, so yeah just to verify on the rust approach
It is very similar, in both cases 1 worker means 1 thread (CPU core). That doesn’t change between Rust and TypeScript.
You can certainly use the same approach with pool of workers if you want in Rust too.
There might be cases where you want to have multiple routers in the same worker, but I found that one router per worker is a simple rule of thumb that works well and is easy to manage.
but one issue though if spinning up worker per router(agree on the easy to manage), if say the cpu only has 4 cores, wouldn’t that limit only having 4 routers if using this approach, but i also see rust uses os thread so the limit shouldn’t be just 4 please correct me if i am wrong on this
You can use any number of workers on any number of CPUs in both TypeScript and Rust. Worker doesn’t use the whole CPU core unless needed, so you can have 20 workers on dual-core CPU without issues.
Whether worker is running in a thread or process is irrelevant here for the most part.
So, are Router objects inside a Worker are just to group Transports, Producers and Consumers? A helper for application logic to provide a security mechanism like trying to access Producers from another Router where we don’t have access to?