开发者

Multiprocessor with v8 and node.js

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 开发者_如何学JAVAto 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.


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.


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.


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.)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜