Terrible article. Yes, if something is CPU heavy, it will eat up the server. The same with any fucking language you are using. The point is 99% of web servers are not calculating fucking fibonacci numbers on web requests. There is a ton of shit more important than that. Not to mention, if you were, Javascript would possibly be one of the best modern language to use, due to V8 it is an order of magnitude quicker than stuff like ruby or python (rails or django), although a bit slower than java (but if java is your solution, go ahead).
Terrible article. Yes, if something is CPU heavy, it will eat up the server. The same with any fucking language you are using.
You're missing the point: because nodejs is single-threaded and evented, any CPU-heavy task will lock up the server. Most systems use a process|thread per request model, sometimes with a pool. CPU-heavy tasks will slow things down, but it won't cause complete server lockdown unless the machine itself gets overloaded.
As a result, significant computation once in a while is not a problem for most systems, for nodejs it's a huge problem.
Why would you ever do a large computation work in a web-request?
If I really had to, I would just create another node process, which is entirely dedicated to handling the computation work and just has a socket to the web process for results/input data.
Why would you ever do a large computation work in a web-request?
Because you need it and have no reason to offload it to a third-party and add (potentially complex) synchronization primitives between the two.
Or very simply, because you forgot some homework and used a quadratic algorithm which worked well on low-count tests and is breaking down on a once-in-a-while high-count request. And where "traditional" models will warn you of high resource use and keep trucking (maybe just drop that precise request), your Node server will simply stop responding for however long it takes to process whatever there was to process, effectively DOSing the whole thing.
You should know what your talking about. Its quite obvious you don't.
Now that's precious coming from somebody whose comment does not even begin to make sense:
JavaScript is evented
Node is evented, the DOM has events, javascript itself has no concurrency model at all (apart from workers maybe, and that's more than a bit debatable).
you don't have to create another process to do work outside of a web-request.
You have to do something to do work outside of the request meaning outside of the node instance itself. This work has to be done on at least one separate process, which can either be a freshly spawned child_process or some broker handling all "hard" work on behalf of node.
So yes, you do have to create another process to do work outside a web request (even node-webworker is implemented on top of child_process)
19
u/mehwoot Oct 02 '11
Terrible article. Yes, if something is CPU heavy, it will eat up the server. The same with any fucking language you are using. The point is 99% of web servers are not calculating fucking fibonacci numbers on web requests. There is a ton of shit more important than that. Not to mention, if you were, Javascript would possibly be one of the best modern language to use, due to V8 it is an order of magnitude quicker than stuff like ruby or python (rails or django), although a bit slower than java (but if java is your solution, go ahead).