Hacker News new | past | comments | ask | show | jobs | submit login
A template for setting up Node.js-backed web apps on EC2 (rsms.me)
42 points by tonyskn on March 23, 2011 | hide | past | favorite | 6 comments



Personally, I put our main node.js based app behind nginx which is behind varnish. Varnish caches any get requests, Nginx balances multiple instances of our app running (currently 5 instances) as well as handles x-sendfile requests.


I'd like to learn more about how your setup works and how one would go about doing it. Do you have any suggestions on where to read up on it?


There's really not much to it -

Varnish runs on port 80 - the only real rules here is to make sure you always return(pass) on anything other than GET and HEAD requests.

Nginx runs on port 8080, which Varnish passes all requests through. I set up an upstream cluster pointing to 5 local instances running on the local server (ports in use in this case are 8081 through 8085). By proxy_pass'ing it to the upstream cluster it will round robin through my instances (no need for ip_hash or weighting currently).

My node.js app allows me to send it it's port as a command line option. By using monit I can ensure that each of the 5 instances are running.

One last thing - I was having too many performance issues with having node.js send large files (the application in question is a document management system) back to the client. It does it, but the RPS was too low for our requirements. By implementing XSendfile in Nginx, we can have node.js pass along the appropriate header to Nginx, which then sends the file along. At this point it would also become cached in Varnish. RPS increased to more than acceptable levels, and the system runs a lot smoother now.

If a better writeup is needed, I would be more than happy to try and get something together today or tomorrow..


A writeup would be great, I'd love to read more about this.


OK, will see what I can do!


Nice, I'm writing up about EC2 as well, though in a different context ... I'm very fond of it too (for these small projects).




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: