简体   繁体   English

mongodb,express.js app部署最佳实践

[英]mongodb, express.js app deployment best practices

I have an API written in express.js , the db is mongo . 我有一个用express.js编写的API,db是mongo I'm planning to use mlab to deploy the DB. 我打算用mlab来部署数据库。 I don't really understand where to deploy the express api? 我真的不明白在哪里部署express api? Can i use AWS for api only? 我可以仅将AWS用于api吗? Is there any provider where i can host my DB and API at the same time? 是否有任何提供商可以同时托管我的数据库和API? What are the best practices for deployment of these APIs? 部署这些API的最佳实践是什么?

"Best practices" is based on your needs. “最佳实践”基于您的需求。 The current trend is to move everything to the cloud. 目前的趋势是将一切都迁移到云端。 So services such as AWS Elastic Beanstalk , Heroku , Azure App Service , and more will allow you to easily host your Express app with little to no setup/configuration on your end. 因此,诸如AWS Elastic BeanstalkHerokuAzure App Service等服务将允许您轻松托管您的Express应用程序,而您几乎不需要设置/配置。

Each of the providers I've listed above have their own flavor of a NoSQL document storage. 我上面列出的每个提供商都有自己的NoSQL文档存储风格。

If you're set on NoSQL, then it's probably less of a headache for you to stick with mLab. 如果您使用NoSQL,那么坚持使用mLab可能不那么令人头痛。

Here is my approach in AWS for simple apps 以下是我在AWS中针对简单应用程序的方法

  1. Number of servers :1 服务器数量:1

  2. Application server and DB server are in same machine. 应用服务器和数据库服务器在同一台机器上。

  3. Setting up mongodb and nodejs in ec2 server with nginx as web server. 使用nginx作为Web服务器在ec2服务器中设置mongodb和nodejs。

  4. Nginx listen on port 80 and nodejs application running on port 3000 Nginx侦听在端口3000上运行的端口80和nodejs应用程序

  5. Using nginx reverse proxy to access the API endpoints 使用nginx反向代理访问API端点

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM