0

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?

Carlos Bribiescas
  • 4,197
  • 9
  • 35
  • 66

1 Answers1

2

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

Amadan
  • 191,408
  • 23
  • 240
  • 301