简体   繁体   English

部署 web 应用程序的最佳实践

[英]Best practice to deploy a web application

I'm building a full-stack web-application.我正在构建一个全栈 Web 应用程序。 I'm using Vue.js for the frontend, Spring Boot for the back-end, and PostgreSQL docker container for the database.我将 Vue.js 用于前端,Spring Boot 用于后端,PostgreSQL Z05B6053C41A2130AFD6FC3BE58 用于数据库。 However, I am very curious about once I finish developing my web-application where and how should I deploy it.但是,我很好奇一旦我完成了 Web 应用程序的开发,我应该在哪里以及如何部署它。

I listed my questions below:我在下面列出了我的问题:

  • where should I deploy my full-stack app, like AWS, GCP, Hiroku, or any other platform.我应该在哪里部署我的全栈应用程序,例如 AWS、GCP、Hiroku 或任何其他平台。
  • what is the best practice for deploying my frontend, backend, and database?部署前端、后端和数据库的最佳实践是什么? Like, should I deploy my frontend on one server and the backend on another server?比如,我应该将前端部署在一台服务器上,将后端部署在另一台服务器上吗? If I deployed in different servers for frontend and backend, how would they communicate to each other?如果我为前端和后端部署在不同的服务器中,它们将如何相互通信? Or should I deploy in the same server?还是应该部署在同一台服务器上?
  • Where should I deploy my Postgres Docker container?我应该在哪里部署我的 Postgres Docker 容器? I know in AWS there is a service called RDS but how would I use it with my Postgres Docker container or is there a better way?我知道在 AWS 中有一项名为 RDS 的服务,但我如何将它与我的 Postgres Docker 容器一起使用,还是有更好的方法?

Thank you!谢谢!

  1. Choosing a cloud provider may be based on many factors: price, what services do they offer, familiarity and more.选择云提供商可能基于许多因素:价格、他们提供的服务、熟悉度等等。

  2. The question should not be "should I deploy FE and BE separately" but rather: "what is the trade-off, for my app, to deploy them separately vs. together".问题不应该是“我应该单独部署 FE 和 BE”,而是:“对于我的应用程序来说,分别部署它们与一起部署它们的权衡是什么”。 When the code grows and gets more mature and different people/teams work on it - it makes sense to decouple BE from FE, but if it's a pet project of a single person, then deploying them together is simpler operation-wise (you don't have to coordinate deploys for example).当代码增长并变得更加成熟并且不同的人/团队在它上面工作时 - 将 BE 与 FE 分离是有意义的,但如果它是一个人的宠物项目,那么将它们部署在一起在操作方面会更简单(你不需要)例如,必须协调部署)。

  3. RDS supports postgres, you don't "deploy your postgres docker on RDS" but rather spin an RDS instance with postgres on it RDS 支持 postgres,你不要“在 RDS 上部署你的 postgres docker”,而是旋转一个带有 postgres 的 RDS 实例

1.Before deploying a web application besides cost, these are the following things you should consider 1.在部署 web 应用程序之前,除了成本之外,这些是您应该考虑的以下事项

  • For application development, choose PaaS.对于应用程序开发,选择 PaaS。 The infrastructure is managed by a vendor, which gives you more time to focus on your application code.基础架构由供应商管理,让您有更多时间专注于应用程序代码。
  • For application development, choose a platform enabled for both manual and automatic horizontal scaling of your application.对于应用程序开发,选择一个支持手动和自动水平扩展应用程序的平台。
  • For green-field applications, design apps that are stateless.对于未开发的应用程序,设计无状态的应用程序。
  • For legacy or existing applications, choose a PaaS provider that supports both stateful and stateless applications.对于遗留或现有应用程序,请选择同时支持有状态和无状态应用程序的 PaaS 提供程序。
  • Choose a database that is scalable and located on a separate server or container from your application code.从您的应用程序代码中选择一个可扩展且位于单独服务器或容器上的数据库。 Then you can scale the database independently.然后您可以独立扩展数据库。
  • Choose a cloud provider that enables you to both deploy and scale your application infrastructure across multiple geographies throughout the world.选择一个云提供商,使您能够在全球多个地区部署和扩展您的应用程序基础架构。
  • Develop using REST-based web services.使用基于 REST 的 web 服务进行开发。
  • Choose a cloud provider that meets all of the previous requirements with the added feature of integrated continuous integrations and continuous delivery tools in the platform.选择满足所有先前要求的云提供商,并在平台中添加集成持续集成和持续交付工具的附加功能。
  • Avoid being locked in by a vendor.避免被供应商锁定。

2.One of the questions that arise when we talk about the web development process is, whether it is useful to keep the frontend-backend together or they should be kept separate. 2.当我们谈论web开发过程时出现的一个问题是,将前端-后端保持在一起还是应该分开是否有用。

Personally speaking, You don't have to use different servers for different components.就个人而言,您不必为不同的组件使用不同的服务器。 It will work very efficiently even if you've only a single combined server.即使您只有一个组合服务器,它也会非常有效地工作。

If your single combined server is incapable of handling a large number of database requests and web server requests from your visitors, Optimize your back-end and front-end codes and normalize the database, Even after doing this, if there are no efficiency increases as you expected, then only you need to use two servers for both to increase your efficiency.如果您的单个组合服务器无法处理大量的数据库请求和来自访问者的 web 服务器请求,请优化您的后端和前端代码并规范数据库,即使这样做了,如果没有效率提升为如您所料,那么您只需要同时使用两台服务器即可提高效率。

The problem with different servers for different uses is cost and management.不同用途的不同服务器的问题是成本和管理。 You've to pay as double ( in most cases ) as you're paying for a single server for two servers.您必须为一台服务器支付两台服务器的费用(在大多数情况下)。 The managing of both servers is quite difficult, if your application is large enough, you may have to appoint more than one server manager.两台服务器的管理都相当困难,如果您的应用程序足够大,您可能需要指定多个服务器管理器。

I prefer to use a single combined server and for large-scale use, I prefer to use just a database on different servers and both front-end and back-end servers on a single server.我更喜欢使用单个组合服务器,对于大规模使用,我更喜欢在不同服务器上只使用一个数据库,在单个服务器上同时使用前端和后端服务器。

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

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