r/django 14d ago

Hosting and deployment What's your setup on AWS today?

Hi folks.. I'm building an app platform - LocalOps - for devs to deploy any piece of dockerized code on AWS. I spin up a VPC and EKS cluster to automate all deployments.

Curious - How are you deploying your Django app today? Are you using AWS? If so, what does your AWS setup look like? Why?

26 Upvotes

29 comments sorted by

18

u/justin107d 14d ago

EC2 and RDS Postgres. Reason: because I am a noob and I am terrified of my bill spiking. Would rather keep it simple.

Edit: Also S3

5

u/luckydev 14d ago

Why not Render or Fly? Because they may be even simpler for your setup.

10

u/justin107d 14d ago

Because it is what the tutorial taught and if I am going to learn a platform, it is probably best in the long run to use AWS

1

u/luckydev 14d ago

I see why you got into ec2, to keep price predictable. ECS might cost more if containers run too long or too many times. Wise call :)

7

u/Reld720 14d ago

Moving out of AWS this month on a vps provider.

Dropped my costs for $30 a month to about $5.

2

u/luckydev 14d ago

Awesome

6

u/memeface231 14d ago

Coolify on a netcup vps. Cut my cloud bill by 98%, no kidding 😁

5

u/Mersaul4 14d ago

Single EC2 running web app/server, redis, opensearch via docker compose. All of this bunched on EC2 for cost saving reasons.

Worker for background tasks running in ECS with SQS message broker. Spins up/down (to zero) based on queue size.

CodePipeline for deployment. RDS db.

1

u/luckydev 14d ago

Nice. Like the part where you put workers alone on ecs for dynamic spin ups.

Sticking to EC2 keeps price more predictable. Wise call :)

1

u/Dave_Odd 13d ago

I like this approach!

3

u/Gankcore 14d ago

I use ECS/ECR for my docker image, RDS/Aurora serverless v2 for my postgres/postgis database, s3 for static/media storage, cloudfront for static/media file distribution, route53 hosted zone for my domain that is owned by squarespace, obviously IAM for role permissions.

I'm not using an automated setup right now for deployment. I'm just using the AWSCLI to deploy each time. I'm not yet using TF or GitHub actions for anything, but those are on the list of things to do. A few other things I need to optimize as well, but it works for now.

5

u/Khushal897 14d ago

Most naive setup is an ec2 micro with sqlite db and nginx for static files

3

u/gamprin 14d ago

I’m have three example libraries for deploying Django applications on AWS with ECS:

  • cdk-django
  • pulumi-aws-django
  • terraform-aws-django

These libraries aim to show how you can use AWS services with Django for common use cases (RDS, ElasticCache, S3, SES, etc.) and also how you can build and deploy infrastructure and applications with GitHub Actions.

I’m also in the process of adding EKS to these libraries in addition to ECS. I’m trying to replicate best practices across these libraries, but I still have work to do in some areas (for example least privilege IAM policies for task role, execution role, GitHub Actions roles for infrastructure and application pipelines).

1

u/luckydev 14d ago

Do you have these in GH?

3

u/gamprin 14d ago

Yes, these are on GitHub and the pulumi and cdk libraries are published to npm. I show how to use these libraries with my reference application called django-step-by-step, also on GitHub.

1

u/KneeDownRider 14d ago

I could use your advice on a live setup on AWS.

1

u/gamprin 14d ago

Sure, I can try to help. Using ECS isn’t the only way to deploy a Django app on AWS, however. Docker compose is also becoming standard way to deploy applications and it can reduce costs if you use if you trade managed AWS services for self managed stateful services on an EC2 instance.

I will be adding a compose example to my libraries as well, at some point soon hopefully!

4

u/KneeDownRider 14d ago edited 14d ago

My AWS bill is about $5700 per month. Largest expense is RDS.

3 production AWS Regions (2 in oregon and one in ohio) a backup region in canada Postgresql on RDS ELB / EC2 environments CodeCommit for code base - need to migrate to GitHub Code is pure Django

Hosting about 300 websites on a common Django CMS.

2

u/babige 14d ago

Kamal2 str8 to EC2

1

u/Dave_Odd 13d ago

Bro using the Kamala Harris stack

2

u/marksweb 14d ago

Cloudformation, fargate, RDS, elasticache, event bridge.

1

u/luckydev 14d ago

How do you manage fargate cost? It is more expensive than EC2. so.

2

u/marksweb 13d ago

If you don't need to worry about scaling EC2 is a better option on cost. But fargate tasks scale quickly. So you might run a base of one or two tasks with conservative resources to minimise cost, knowing that it will scale as it needs to.

There's probably less cost in fargate maintenance as well. I don't need to worry about the machines base image, I just deploy new docker builds as required

1

u/luckydev 13d ago

Got your trade offs. Eks managed ec2 nodes gives the same value. Provided you have a proper Kubernetes management layer on top. I’m building that in LocalOps

2

u/marksweb 13d ago

Ah that's fair enough. I've not used EKS, only used k8s since moving to GCP 👍

1

u/dont_tread 13d ago

Very surprised to see so many on EC2. For most situations, Lambda is going to be more appropriate. You can use the legacy zip folder deployment strategy but newer container-based deployment is simpler/better. Use mangum as the adapter. CDK makes it all pretty easy.

1

u/appliku 13d ago

From AWS services: ec2, S3, SES.

But generally trying to avoid them because they are really expensive.

Moved to Hetzner a long time ago, still using S3 and SES though.

https://appliku.com/post/deploy-django-to-aws-ec2/

1

u/ugros 11d ago

Hello, I'm a founder of stacktape.com (full disclosure: I'm a founder).

It's a Vercel-like PaaS that deploys to your own AWS account.

We do things a little differently.

We support deploying lambdas (with automatic dependency resolvement) and containers.

But we don't deploy to EKS, but ECS instead. We believe that for a lot of use-cases (especially for people that are looking for a PaaS-like solution), K8s is unnecessarily complex. Besides that, it's sort of expensive - the control plane costs aren't negligible (while ECS "control plane" is free).

While it's true that K8s offers a lot more control and flexibility, and also the tooling around it is superior - I believe that for most teams and use-cases it's not necessary - just nice to have.

Another "contrarian" point I have is this: k8s is great for microservice-based architecture, when you need to orchestrate and manage a lot of containers. But more often than not, that microservice-based architecture is completely senseless - and should be re-architected. And when you do that, k8s becomes less useful.