简体   繁体   中英

Downside of node.js?

Disclaimer, my knowledge of node.js a few articles mostly summarized by this http://en.wikipedia.org/wiki/Node.js

That said, so my understanding is that it's supposed to be very quick because it avoids the overhead of threading. It puts everything into a single loop instead of doing the overhead of switching between processes.

I assume there is a reason why there is a sophisticated method of switching contexts completely in between threads. My question is, what is the benefit of having threads over the node.js approach?

Node.js is extremely fast with IO-intensive tasks, since its event model supports IO delays perfectly. On the other hand, it is completely incapable of doing CPU-intensive tasks without stopping everything. Thus, if you need some heavy calculation, you will want to fork off a worker to do it for you.

Threaded model switches contexts automatically, whatever the thread is doing, and thus can handle CPU-intensive jobs without impacting other threads negatively too much. (Or rather, they will still work, only slower if CPU capacity is reached.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM