

Node.js via CGI - pufuwozu
http://brianmckenna.org/blog/nodejs_via_cgi

======
kennu
Wtf... What's the point of using Node.js if you don't use it as an event based
HTTP server.

~~~
pufuwozu
Good question. I just want to point out that yes, node.js through CGI is a
massive bastardisation.

The main reason for it was that I (and possibly some other people) want to
make websites using JavaScript and then just chuck it on some cheap shared
server. The reason specifically for node.js is because it's arguably the most
popular form of server-side JavaScript.

Yes, CGI spawns a new process for each request but V8 (the node.js VM) is
crazy-insane fast. I haven't done any tests but my intuition (which is quite
probably wrong) tells me that the cost of forking V8 (lightweight) is probably
not as bad having a Python process ready and serving from it.

By the time my blog receives enough requests that having a persistant process
is necessary, I would have moved on to caching. Caching is _the_ answer for
blogs.

Running node.js via CGI for a complex web application is definitely not the
final answer. I've made the libary very similar to the built-in event based
HTTP server so the cost of switching when the application gets too big is very
insignificant. Find, replace 'cgi' -> 'http', chuck on a virtual machine and
go!

