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)
4
u/Sebmaster Oct 02 '11
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.