Here's the scenario I anticipate: I have an app written in PHP which has a domain layer (complete with validators, etc). I want to use node.js for my web services for performance in high concurrency situations. If I create a command line interface for my php domain layer (see below), will this give me better performance than just using Apache? Is this even a good way to do this? I'm new to node.js and am trying to get my bearings. Node: The command line interface for the domain layer will return json encoded objects.
//Super simple example:
var http = require("http");
var exec = require('child_process').exec;
function onRequest(request, response) {
exec("php domain-cli.php -model Users -method getById -id 32", function(error, stdout, stderr){
response.writeHead(200, {"Content-Type": "application/json"});
response.write(stdout);
response.end();
});
}
http.createServer(onRequest).listen(80);