Search code examples
djangoamazon-ecsaws-fargate

django application on AWS fargate with postgresql persistent database


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.


Solution

  • 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.