Hacker News new | ask | show | jobs
by nomailing 3818 days ago
Don't you think nginx is better for serving static files? I first served directly croon node with express and did a test with chrome with a simulated modem connection speed. A simultaneous fast client was blocked because the number of connection nodejs/express was exhausted by the slow modem connection getting a lot of js files...

I think I also read many other blogs suggesting serving static files with nginx in front of nodejs. Are you sure that this does not make sense?

1 comments

It's not so much a matter of 'better' vs 'worse' as a balance between complexity and speed. node has very fast IO - that's what it's known for - and unlike Python or Ruby it can handle static files at speed: http://i.stack.imgur.com/amngX.png (from the second post at http://stackoverflow.com/questions/9967887/node-js-itself-or... which provides some excellent discussion). nginx is faster, but small projects that don't need load balancing may benefit from having less software to install.

As the article mentions, you'll probably want a load balancer for high availability. Whether you use haproxy or nginx for that is a whole different discussion.

Faster than Ruby or Python doesn't mean anything if it's objectively slow. And it is. I've only been able to serve a small handful of concurrent users at a time with Express. I'm talking 5 or 6 before things get out of hand.

You should aim to have the bulk of your payload be static, and all of the static payload be served by apache or nginx. It's the difference between getting good feedback from a Show HN post or completely missing out and looking like a fool.

> I've only been able to serve a small handful of concurrent users at a time with Express.

Something's massively wrong with your node setup. node won't be as fast, but it should be on the same order of magnitude as nginx: https://github.com/observing/balancerbattle (or any other benchmark)