4 ms·
See, this confuses me. From working with Node and understanding its core architectural concept, the single event loop, I find Node's worst use case to be front
by virmundi 12y ago
See, this confuses me. From working with Node and understanding its core architectural concept, the single event loop, I find Node's worst use case to be front end development.
Server side rendering takes time, even 10 ms. On an single event loop, that is terrible. You can only server 100 request/second due to the 10 ms limit. While it is nice that you can move a request into the backing queue while waiting for the data, you're capped at 100 requests/second.
Where I think Node shines is low level network management. Netflix could use it to pipe video data from one of its boxes out to a user. It's got that kind of work built right into it. As a result, I think that storage, spooling and possibly even sending would be best in Node. Those are largely I/O bound, schlep data from port to port operations.
My understanding of PHP is that it's really hard to have really global variables. Compare this to Node.js where Javascript naturally does this. I can't find it now, but I remember back when Node was young a guy had an issue with his shopping cart system. People's orders were screwed up. Turns out that he missed a `var` in a function. PHP, I don't think, could do this easily since the widest screw up scope is file. So you're still limited to request scoping.
- jdhawk 12y agoWell...there is the global operator, and it takes into account the entire running "stack of files" - so include your config.php, lib.php wrappers, which in turn include other files for your application/framework, and then use the global $var tag in every function, and you get a reference to a truly global variable. http://php.net/manual/en/language.variables.scope.php http://php.net/manual/en/language.variables.scope.php PHP also has "superglobals" http://php.net/manual/en/language.variables.superglobals.php http://php.net/manual/en/language.variables.superglobals.php
- euroclydon 12y agoWell, Node has clustering, and there is probably some nifty load-balancer that works with Nginx and Node. http://nodejs.org/api/cluster.html http://nodejs.org/api/cluster.html
- bmurphy1976 12y agoNginx is a very primitive load balancer. Use haproxy.
- guard-of-terra 12y agoWhy, it's nice? Throw several worker processes in and you can easily handle 1000 rps per VM. And no, you don't really need global variables in frontend that much; and backend PHP programs (which you should not do of course) have long-lived global variables.