Live data from Hacker News

Node.js in Production

blog.carbonfive.com

11–20 of 22 posts

Re: Node.js in Production

#11
> Another Note: This runs on port 3000. Making it run on port 80 would be possible using a reverse proxy (such as nginx), but for this setup we will actually run the app servers on port 3000 and the load balancer (on a different server) will run on port 80.

This comes up a lot. In addition to the reverse proxy, you can also:

-- redirect port 80 to port 3000

  iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3000
-- use authbind to grant port 80 access to an unprivileged user http://manpages.ubuntu.com/manpages/hardy/man1/authbind.1.ht...

Re: Node.js in Production

#12
post #5

Earlier quoted context omitted.

https://wordpress.org/plugins/tags/wp-cache

we have super-cache enabled and the apache KeepAliveTimeout down to 1 second (which killed us in the past). but hacker news still sends a crushing amount of traffic.

I don't think that's true. I've hit the front page a couple times and actually got very little traffic, and definitely nothing that my $5 vps with no caching couldn't handle.

Re: Node.js in Production

#13
post #11

> Another Note: This runs on port 3000. Making it run on port 80 would be possible using a reverse proxy (such as nginx), but for this setup we will actually run the app servers on port 3000 and the load balancer (on a different server) will run on port 80. This comes up a lot. In addition to the reverse proxy, you can also: -- redirect port 80 to port 3000 iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j R…

great tip, I'll add this in

Re: Node.js in Production

#14
post #12

Earlier quoted context omitted.

we have super-cache enabled and the apache KeepAliveTimeout down to 1 second (which killed us in the past). but hacker news still sends a crushing amount of traffic.

I don't think that's true. I've hit the front page a couple times and actually got very little traffic, and definitely nothing that my $5 vps with no caching couldn't handle.

were you running wordpress? i think the traffic that HN sends crushes wordpress specifically. who knows... maybe it's just our wordpress config. we're gonna port it over to a static site generator anyway.

Re: Node.js in Production

#15
post #12

Earlier quoted context omitted.

I don't think that's true. I've hit the front page a couple times and actually got very little traffic, and definitely nothing that my $5 vps with no caching couldn't handle.

were you running wordpress? i think the traffic that HN sends crushes wordpress specifically. who knows... maybe it's just our wordpress config. we're gonna port it over to a static site generator anyway.

Probably should switch to static content, a Raspberry Pi could handle the traffic no sweat.

Re: Node.js in Production

#16
post #3
post #2

Why is it always the articles that tell you how to do things in production that take multiple seconds to load and/or throw database errors?

because wordpress! ugh!!

there's an easy fix: http://antjanus.com/blog/web-development-tutorials/fortify-w...

Re: Node.js in Production

#17
post #15

Earlier quoted context omitted.

were you running wordpress? i think the traffic that HN sends crushes wordpress specifically. who knows... maybe it's just our wordpress config. we're gonna port it over to a static site generator anyway.

Probably should switch to static content, a Raspberry Pi could handle the traffic no sweat.

Yes, raspberry pi with handle front page HN. Put free cloudflare in front and you're laughing.

Re: Node.js in Production

#18
post #11

> Another Note: This runs on port 3000. Making it run on port 80 would be possible using a reverse proxy (such as nginx), but for this setup we will actually run the app servers on port 3000 and the load balancer (on a different server) will run on port 80. This comes up a lot. In addition to the reverse proxy, you can also: -- redirect port 80 to port 3000 iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j R…

Which is a better security setup, reverse proxying port 80 to 3000 via a stripped, hardened nginx/apache on 80, or connecting your unpriviledged app directly to port 80 via iptables or authbind?

Re: Node.js in Production

#19
post #11

> Another Note: This runs on port 3000. Making it run on port 80 would be possible using a reverse proxy (such as nginx), but for this setup we will actually run the app servers on port 3000 and the load balancer (on a different server) will run on port 80. This comes up a lot. In addition to the reverse proxy, you can also: -- redirect port 80 to port 3000 iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j R…

I can see how this is useful if you are using a single node.js server as you wouldn't need any proxy in front of it.

However if you are using a load balancer in front of a handful of node.js app servers, does this offer any advantage over just using an arbitrary port > 1024?

Re: Node.js in Production

#20
thank you for doing this, I was just about to slog through figuring this out for myself using most of these tools. This will save me a lot of trial and error!

Small plug, I wrote a node wrapper for digital ocean's API. https://github.com/hortinstein/brinydeep It would be interesting to use it to auto-scale based on feedback from haproxy or the nodes themselves when smashing it with siege.

When i get around to it I might write a followup to your article incorporating that and some of the other features!

Post reply on HN