Scale mediasoup across multiple Workers using pipeToRouter

domain: mediasoup.org · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Create one Worker per CPU core using mediasoup.createWorker() in a loop; keep a workers array and assign new rooms to the least-loaded Worker by tracking each Worker's router count.
  2. When a producer on Router A needs to be consumed by a participant on Router B (different Worker or host), call routerA.pipeToRouter({ producerId, router: routerB }) which creates a Pipe transport pair and pipes RTP between the two Routers.
  3. pipeToRouter returns { pipeConsumer, pipeProducer }; the pipeProducer on the destination Router can be consumed by participants on that Router the same way a regular producer is consumed.
  4. For cross-host scaling, implement your own signaling to exchange the PipeTransport connect parameters between hosts, then call pipeTransport.connect() on each side with the remote IP, port, and SRTP parameters.
  5. Monitor each Worker's resource use via worker.getResourceUsage() and redistribute rooms if a Worker approaches capacity (mediasoup documents a guideline of roughly 500 total consumers per Worker as a starting reference).
  6. Handle Worker crashes with the worker 'died' event; restart the Worker and reconnect affected rooms — mediasoup does not auto-restart Workers.

Known gotchas

Related routes

Set up a mediasoup Worker, Router, and WebRtcTransport for a video room
mediasoup.org · 6 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans