Question

I was reading that V8 isn't multithreaded, and can't be by design.

Is this true? Is it really the case that I can have a script optimized to run concurrently (on node.js) but that concurrency can't extend to multiple processors? I kinda thought that was a major reason for a concurrent design.

Was it helpful?

Solution

As for node.js, it's not concurrent but asynchronous. There's a single thread, and a single event loop, that handles all IO in node.js.

There are some tools for concurrency in node.js, that mostly revolve around multiple processes. But like all of node.js, they are in the early stages of development. For example, you can manage multiple worker processes using fugue, or you can use the possibly familiar Web Workers API using node-worker.

OTHER TIPS

For Node v0.8 and above, the https://github.com/audreyt/node-webworker-threads module now provides the same Web Worker API, implemented with native threads aimed for multi-core scheduling, with lower serialization & worker creation overhead compared to process-based node-worker module.

See limiting execution time. It's possible but I'm not sure how likely it is to be as easy as say Java.

Since v0.6 you can use the cluster facility.

The communication between the separate node processes incurs some overhead, and because of this, the support of v8 isolates was considered for some time, but eventually it was not pursued due to inadequate improvement vs complexity tradeoff.

(The v8 isolates would enable the use of threads instead of processes, allowing for more efficient communication.)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top