如何在 gcp 上部署 angular-spring-postgres 应用程序?
How can I deploy an angular-spring-postgres application on gcp?
我是 GCP 的新手,目前,我尝试在他们的服务上部署我的所有应用程序。
对于单个容器中的应用程序,我使用了我非常喜欢的 CloudRun。
现在我想部署一个在前端使用 Angular 并在后端使用 spring 和 SQL-DB (Postgres) 的应用程序。每个部分都在自己独立的容器中。
尽管 CloudRun 或 GCP 是否有更合适的服务,但如果我想托管可扩展且无服务器的应用程序,我应该考虑使用它吗?那么在 GCP 上是否有前后端架构应用程序的最佳实践?
云运行 运行s 无状态容器。它不区分前端和后端,或工人工作。
您可以 运行 您的前端、后端、管理代码库作为 Cloud 运行 服务。
在这些旁边,您为操作数据库设置 Cloud SQL,并将 Cloud 运行 服务与 Cloud SQL 连接器连接,以便它们能够用于 read/write 查询。
我推荐您使用这些服务:
- Cloud SQL 托管数据库。为您代劳高效
- 云 运行 用于业务层(spring 应用程序)。
小心,spring 冷启动可能需要几秒钟。我写了 an article on this (the article is quite old and the perf are now better on Cloud Run, but the latency on the first request exists (and take 5 - 7s for an hello world container)). Add several CPU (4 is a good number) to speed up the cold start or use the --min-instance parameter for this (or other solution that you can find in one of my articles)
- 对于前端,我建议您将静态文件托管在云存储上。
- 要在 Internet 上提供此服务,请在其前面放置一个负载均衡器
- 创建 serverless network endpoint group (NEG) for Cloud Run service
- 创建 Cloud Storage backend to serve the static files.
- 使用您想要的域并在 SSL 中提供它
- 可选地,使用 CDN 来缓存您的静态文件。
我是 GCP 的新手,目前,我尝试在他们的服务上部署我的所有应用程序。
对于单个容器中的应用程序,我使用了我非常喜欢的 CloudRun。
现在我想部署一个在前端使用 Angular 并在后端使用 spring 和 SQL-DB (Postgres) 的应用程序。每个部分都在自己独立的容器中。
尽管 CloudRun 或 GCP 是否有更合适的服务,但如果我想托管可扩展且无服务器的应用程序,我应该考虑使用它吗?那么在 GCP 上是否有前后端架构应用程序的最佳实践?
云运行 运行s 无状态容器。它不区分前端和后端,或工人工作。
您可以 运行 您的前端、后端、管理代码库作为 Cloud 运行 服务。
在这些旁边,您为操作数据库设置 Cloud SQL,并将 Cloud 运行 服务与 Cloud SQL 连接器连接,以便它们能够用于 read/write 查询。
我推荐您使用这些服务:
- Cloud SQL 托管数据库。为您代劳高效
- 云 运行 用于业务层(spring 应用程序)。
小心,spring 冷启动可能需要几秒钟。我写了 an article on this (the article is quite old and the perf are now better on Cloud Run, but the latency on the first request exists (and take 5 - 7s for an hello world container)). Add several CPU (4 is a good number) to speed up the cold start or use the --min-instance parameter for this (or other solution that you can find in one of my articles)
- 对于前端,我建议您将静态文件托管在云存储上。
- 要在 Internet 上提供此服务,请在其前面放置一个负载均衡器
- 创建 serverless network endpoint group (NEG) for Cloud Run service
- 创建 Cloud Storage backend to serve the static files.
- 使用您想要的域并在 SSL 中提供它
- 可选地,使用 CDN 来缓存您的静态文件。