4 ms·
We all have different performance requirements, but in my experience, when you actually care about the performance of CPU intensive task, child_process.fork or
by iends 10y ago
We all have different performance requirements, but in my experience, when you actually care about the performance of CPU intensive task, child_process.fork or WebWorkers are still insufficient.
Instead, sometimes you use node native modules, sometimes you separate you child_process.spawn something written in Go, C++, or Rust(,etc), and sometimes you set up a separate work "queue" to pass work either on the same machine or over the network. I've used both kafka, zeromq, or even just files on the s3. A linux domain socket is nice too.
- ankurdhama 10y agoThe performance of the CPU bound task and performing any CPU bound task on the main IO thread are 2 different things. The article was about the problem you face when you do CPU bound task on the main IO thread. The WebWorkers and other approaches are about how to avoid using the IO thread to do CPU tasks. How the performance of those CPU tasks is depends on other factors. You can use WebAssembly or asm.js code to reach the performance of natively compiled code.