Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Expressjs to production

I am new to expressjs, I want to deploy an expressjs app to production. Based on my googling, here's the setup on rackspace I am thinking:

1 Load balancer + 2 server + Run app with forever

My questions are:

  1. What engine shall I use to run the app? nginx?

  2. how many app can I run per server?

Thank you.

like image 880
Johnny Avatar asked Aug 10 '11 17:08

Johnny


People also ask

Can I use Express in production?

You can use it and the related StrongLoop tools to: Build and package your app locally, then deploy it securely to your production system. Automatically restart your app if it crashes for any reason.

Can NodeJS be used in production?

Node. JS is ideal for fast, lightweight, real-time web applications such as audio/video streaming, browser games, chats, collaboration tools social media, time trackers, and much more. For this reason, many companies decide to use Node. js in production.

Is ExpressJS outdated?

Express has not been updated for years, and its next version has been in alpha for 6 years. People may think it is not updated because the API is stable and does not need change. The reality is: Express does not know how to handle async/await .


2 Answers

  1. If you are serving static files or using any of nginx's reverse proxy features, you can use nginx. But if not, since your servers are behind a load balancer, nginx isn't necessary at all.

  2. The rule of thumb is one node.js/express.js process per core. Have a look at cluster to help you manage this. Make sure your load balancer knows about all the node.js processes you are running (and is not just load balancing between one IP/port pair on each server).

Update: Node.js now has cluster built in out of the box.

Also, if you are deploying on Ubuntu you can use upstart instead of forever if you like.

like image 179
Peter Lyons Avatar answered Oct 16 '22 18:10

Peter Lyons


You need nodejs installed on your machine to run nodejs. nginx is a server used for reverse proxy and a load balancer. Also you can run the app through pm2 instead of forever which will handle all the clustering and running your app in background.

like image 1
Rubin bhandari Avatar answered Oct 16 '22 20:10

Rubin bhandari