Deploy node.js in production

后端 未结 2 1261
夕颜
夕颜 2021-01-21 17:36

What are the best practices for deploying a nodejs application in production?

I would like to know how deploy for production Api\'s nodejs is being done

相关标签:
2条回答
  • 2021-01-21 18:12

    There are few main types of deployment that are popular today.

    1. Using platform as a service like Heroku
    2. Using a VPS like AWS, Digital Ocean etc.
    3. Using a dedicated server

    This list is in the order of growing difficulty and control. So it's easiest with PaaS but you get more control with a dedicated server - thought it gets significantly more difficult, especially when you need to scale out and build clusters.

    See this answer for more details on how to install Node on a VPS or a dedicated server:

    • how to run node js on dedicated server?
    0 讨论(0)
  • 2021-01-21 18:12

    I can only add from experience on AWS using a NAT Gateway which is a dedicated Node server with a MongoDB server behind the gateway. (Obviously this is a scalable system and project.)

    1. With or without Docker, you need to control the production environment. This means clearly defining which NPM libraries you will need for production, how you handle environment variables and clusters for cores.

    2. I would suggest, very strongly, using a tool like PM2 to handle clusters, server shutdowns and restarts and logs. (Workers & slaves also if you need them and code for them).

    This list can go on and on, but keep in mind this is only from an AWS perspective. Setting up a Gateway correctly on AWS is also not an easy process. Be prepared for some gotcha's along the way.

    0 讨论(0)
提交回复
热议问题