Worker-based threading

Can I instantiate Worker within the context of a worker? I'm attempting to shim a Rust wasm worker to support web-spawn (https://github.com/tlsnotary/tlsn-utils/blob/dev/web-spawn/js/spawn.no-bundler.js), which is a refactored version of wasm-bindgen-rayon. The WASM I'm building depends heavily on "threading", but it will likely work to simulate it with the workerd global event loop.
5 Replies
FrozenFire
FrozenFireOP2mo ago
Putting some notes here about my findings. I think the limit that will most significantly affect this is simultaneous open connections.
FrozenFire
FrozenFireOP2mo ago
FrozenFire
FrozenFireOP2mo ago
https://developers.cloudflare.com/workers/runtime-apis/bindings/service-bindings/#limits In theory, a request can call up to 32 different workers, and so you could in theory spawn a bunch of "thread" workers in the service bindings, and then call them.
Cloudflare Docs
Service bindings
Facilitate Worker-to-Worker communication.
FrozenFire
FrozenFireOP2mo ago
But, because you can only make 32 calls total, I imagine that you would want to use the fetch handler to instantiate a worker-to-worker websocket, and send work via those websockets. So, you could open six, unless you got into a more complicated architecture where you have your "request" worker spawn one websocket to 6, and then have a special call which multiplexes connections to additional workers.
FrozenFire
FrozenFireOP2mo ago
https://github.com/cloudflare/workers-wasi WASI workers is promising, as it maybe supports wasmtime?
GitHub
GitHub - cloudflare/workers-wasi
Contribute to cloudflare/workers-wasi development by creating an account on GitHub.

Did you find this page helpful?