Mikito Takada writes about node.js, JavaScript patterns, benchmarking, WordPress setup and the startup mindset.
HN commenters link his node.js event loop explanation to clarify how Node handles requests, plus his WordPress multisite and SSH tunneling guides.
First: node is freaking amazing. I've been writing python CGI on Apache for the last few years, but can easily see myself moving to:
nginx -> Static html/javascript/images/css
node.js -> API
Apache -> old Python CGI stuff I still want (beautiful soup, for instance)
To me, this stack is a lot more comfortable, and is a lot faster.
----
Here are a couple of things that this tut misses.
1) You need to talk to your database. This will become immediately apparent when you try to do anything. You can google around, which will lead you to stack overflow, or you can just listen to me right here and use "mysql".
npm install mysql
Easy.
2) Callbacks. This is freaking huge. node will not make any sense to you if you do not understand this. For instance, if you have a function called "get_username()" (Hi! I have a function called get username, I'm speaking from a mistake I made about this!), and you call it like this:
username = get_username();
res.write("Hi, you are: " + username);
res.end("buhbye!");
Your page is just going to crash because username is undefined. This is because node is nonblocking. It doesn't wait for get_username() to return before continuing...meaning your server will end before get_username() finishes.
This is a problem.
So what you need to do won't make sense at first (and maybe I'm doing this wrong, correct me if I am).
you would do:
get_username(res);
and then you would have:
function…
If someone has a recommendation on the best method of configuring this for multiple domains (not subdomains) on a cloud host, I'd appreciate the pointer.
I've found this:
http://blog.mixu.net/2010/05/17/setting-up-multisite-wordpress-3-0-with-multiple-different-domains/
Which references this:
http://www.interconnectit.com/840/wordpress-3-0-multisite-with-multiple-domains-setup/
These assume you can edit your Apache conf, and many cloud hosts don't support that.
I think we are saying the same thing. When I say 'it is still only processing one request at a time', I'm referring to my code execution, not the async stuff or anything else within Node.
I found this to be a good explanation...
http://blog.mixu.net/2011/02/01/understanding-the-node-js-event-loop/
nginx supports http1.1 reverse proxying as of a few weeks ago http://wiki.nginx.org/HttpProxyModule
Mikito Takada (Zendesk) has some really helpful information regarding socket.io + haproxy specific workarounds via http://blog.mixu.net/2011/08/13/nginx-websockets-ssl-and-socket-io-deployment
I know this is a bit different, but maybe you could modify it a bit so you don't need sshuttle?
http://blog.mixu.net/2009/05/05/how-to-watch-hulu-videos-via-ssh-tunneling/
Just make your server listen for ssh on port 80 or 443, and then tunnel away!
This might be interesting for you. Sorry not Node expert myself, but it seems to touch some of your question.
http://blog.mixu.net/2011/02/01/understanding-the-node-js-event-loop/