Nodejs deploy in production

Asked

Viewed 1,031 times

5

What are the best practices for doing the deploy in producing of a Node.JS application?

I would like to know how the deploy in production of API’s Node.JS. My application is today dockerized and running in local environment.

I’d also like to know if I should use the Nginx inside the container and do the deploy from my server on it or simply upload my Node image, which is already running today.

1 answer

1

In general, there are some good practices to be followed, below I list them:

1) Build, if you are using any transpilator such as Babel or TS, build to JS on your server version.

2) Do not use Process Manager, such as PM2 or Nodemon, because they manage processes and open processes, I recommend that you use Kubernetes or Docker Swarm to cluster the application, are more parrudos and efficient in this sense, unless you have in an application a single server instance.

3) have a loadbalancer

4) Avoid exposing your API publicly, always keep Balancer exposed forward,

5) Avoid cluster within your application, native to Node, it tends to consume more resources and generate complexity.

6) Make a URL even if not exposed to the health check audience, basically a URL that checks whether all the services your application depends on are available or even your application.

References https://github.com/i0natan/nodebestpractices#5-going-to-Production-Practices

  • Good. Only complemented that it doesn’t make much sense to use Apache in front of the Node, it makes much more sense to use Ngnix anyway. https://serverfault.com/questions/286960/does-it-make-sense-to-reverse-proxy-node-js-through-apache

Browser other questions tagged

You are not signed in. Login or sign up in order to post.