Django应用程序在AWS Fargate上,带有持久性的PostgreSQL数据库。

huangapple go评论45阅读模式
英文:

django application on AWS fargate with postgresql persistent database

问题

我有一个Django + ReactJS应用程序。它使用PostgreSQL数据库。

目前,我在我的个人电脑上使用Docker Compose,并且能够启动该应用程序。

我有一个卷,其中存储着PostgreSQL数据库。

现在,将此应用程序放入AWS ECS的正确方式是什么?

此外,我不确定如何在Fargate中创建迁移,因为我们可能无法使用SSH访问。

英文:

I have django + reactjs application. It used postgresql db.

Currently i am using a docker compose on my pc and able to spin up the applicaiton.

I have volume where the postgresql db is stored.

Now What the right way to put this application in to the aws ECS.

Also i am not sure how to create migrations in fargate, because we may not have access using ssh.

答案1

得分: 1

你不应该在 ECS 上运行你的数据库。你应该使用 AWS RDS PostgreSQL 或 AWS RDS Aurora(兼容 PostgreSQL)。在 ECS 上设置 PostgreSQL 以获得与 AWS RDS Aurora 提供的性能、可扩展性和容错性相同的性能将会非常困难(可能是不可能的)。

如果你尝试在 ECS Fargate 上运行它,你将不得不使用 EFS 卷进行持久存储,但那些相当慢,所以你的数据库性能会很差。

另外我不确定如何在 Fargate 中创建迁移,因为我们可能无法使用 SSH 访问。

你可以使用 ECS Exec 进入容器,但这对于迁移来说并不是很有效,因为它们需要在 Django 启动之前运行。查看我在 这个问题 中的回答以获取有关如何管理迁移的详细信息。

英文:

You shouldn't run your database on ECS. You should use AWS RDS PostgreSQL, or AWS RDS Aurora (PostgreSQL compatible). It would be extremely difficult (probably impossible) to setup PostgreSQL to run on ECS with the same kind of performance, scalability, and fault-tolerance that is provided out of the box with AWS RDS Aurora.

If you tried running it on ECS Fargate, you would have to use an EFS volume for persistent storage, and those are pretty slow, so your database performance would be bad.

> Also i am not sure how to create migrations in fargate, because we may not have access using ssh.

You can get into the containers with ECS Exec, but that doesn't really work for migrations because they need to run before Django starts up. See my answer to this question for details of how to manage migrations.

huangapple
  • 本文由 发表于 2023年3月31日 19:39:35
  • 转载请务必保留本文链接:https://go.coder-hub.com/75898109.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定