I want to implement a Web Service whose purpose is to execute batch programs stored in a database. The “command line parameters” will be sent to my Web Service as JSON-serialized objects.
Since this is, for the time being, just a personal project, my main concerns are elegance and maintainability, and thus node.js seems like a natural choice. (I know Apache and IIS are mature, proven technologies, but I find them too convoluted and not transparent enough, respectively.)
However, from what I have read, even though node.js can delegate non-sequential tasks to separate concurrent processes, node.js cannot handle these non-sequential tasks concurrently by itself. This poses me the following dilemma:
-
If I create a separate command line utility to be called from node.js, leaving the Web Service as a mere API for the command line utility, I would have to pass huge command line parameters (the serialized JSON objects) from node.js to the command line utility, and would also have to either implement a JSON parser myself or worry about incorporating someone else’s JSON parser in my program.
-
If I handle everything within node.js, I lose concurrent request processing as a feature. Unless there is a way to do true concurrency in node.js, of course.
Neither of these options is palatable enough for my taste. So my question is the following: Is there any way to write truly concurrent programs for node.js, so as to avoid this dilemma?
You can use worker processes, there are modules for that. Also, node v0.8 will have isolated multithreading.