Re:Pushing the performance limits of Node.js
by SignMeTheHELLUp on Friday August 28, 2015 @02:48AM
(#10134030)
But now you've just implemented thread context switching by pulling it's implementation details into your algorithm... Just use a language that supports threading if you have real work to do...
Re:Pushing the performance limits of Node.js
by NathanKP on Friday August 28, 2015 @10:00AM
(#10135427)
Sometimes it is more efficient to implement the context switching yourself. For extremely high performance server use cases such as realtime analytics, streaming video processing, high frequency trading, etc it isn't uncommon to have server code written in C/C++.
It really depends on what your most important metric is. If the most important metric is speed then having more control over context switching is often better.
Done properly this also leads to a low memory process that will grab data from an incoming socket stream, transform it, then push that data back out through an outgoing socket stream, only ever keeping a few MB of the stream in working memory at a time. Slap a cluster of these streaming processes together running on a single box to utilize all CPU cores and you can easily push many Mbps of IO through your server quickly and efficiently.
Additionally even if you do have a heavy blocking system IO operation that you can't break up very well you can increase `UV_THREADPOOL_SIZE` when needed to reduce the impact of the blocking.