2

What are the advantages/disadvantages of using node.js with a connect.vhost directive as a router rather than NGINX using proxy_pass?

2 Answers 2

2

Connect.vhost

pros

  • fairly simple
  • only one server to worry about
  • you won't have multiple processes on the same host fighting for the same memory

cons

  • does not scale beyond 1 core, if you need to cluster beyond one machine, you are back with nginx or similar anyway.
  • you still need a solution to redirect port 80 to node.js (unless you are fine running node as root), such as iptables, or nginx.

nginx

pros

  • this is used by thousands (millions?) of websites as their front-end or only server
  • won't add much overhead
  • you could serve static files directly without having node.js do it

I'd pick nginx pretty much by default, but I could see using Connect.vhost for something I need quick and won't need to scale on.

Sign up to request clarification or add additional context in comments.

6 Comments

Does NGINX balance X Node.js server(s) requests evenly over Y cores? Or does Node.js - no matter what - use a single core.
typically, on a 16 core server, you could run 16 node.js processes, unless you need to run databases or other services. A node.js is pretty much single threaded (although node itself uses a few other threads for house keeping), and you may get to use a bit more than one core during i/o. As a rule of thumb, I use one node.js process === 1 core.
this doesn't mean a single node.js process can't handle 1000s of requests simultaneously. It can. But once you've maxxed out on that process, having more cores is not going to help unless you start more than one process.
Use the cluster module and you can take advantage of all cores with either solution.
So is Node.js server when managed by NGINX interpreted as a process where each process request is paired with the next most available core is are they always utilizing the same core no matter what?
|
2

Connect vhost Advantage: WebSockets just work. You don't have to install and configure nginx. The whole stack is node.js. Behavior may be more customizable to your liking.

Nginx Advantage: Nginx is a mature and stable web server. It's very unlikely to crash or exhibit strange behavior. It can also host your static resources, PHP site, etc.

If it were me, unless I needed some particular feature of Nginx, I'd pick Connect vhost or node-http-proxy for the sake of having an all-node.js stack.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.