Outcomes
- AWS spend down 50%.
- The audit found one service at 99.8% memory. I scaled it up before it ran out.
- A dedicated single-tenant stack, about $400 a month, merged into shared production.
The problem
The company began on Lambda and API Gateway. Long-running and stateful work did not fit, and dev, sandbox and prod ran differently.
Costs grew with the estate: always-on dev, unpruned storage and container images, over-provisioned services, idle NAT gateways in several regions and real-time CDN metrics nobody read.
What I built
- Moved the Django API, Celery workers and supporting services to ECS Fargate behind load balancers, with auto-scaling, PgBouncer, SSM configuration and dedicated database migration tasks.
- Audited 14 days of CloudWatch utilisation against Cost Explorer for every ECS service and Aurora cluster, and set guardrails for CPU headroom and a memory floor of twice the observed peak.
- Built an office-hours scaler in GitHub Actions that stops dev ECS services and Aurora clusters out of hours.
- Turned off real-time metrics on about 60 CloudFront distributions, and added S3 and ECR lifecycle rules.
- Right-sized services, moved eligible work to Fargate Spot, dropped idle regions of the proof-verification service and removed per-region NAT gateways.
- Fixed a cloud-init bug that kept production bastions running all day, and merged a dedicated single-tenant stack into the shared production stack without re-encrypting data.
Architecture and stack
- AWS: ECS Fargate, Fargate Spot, Aurora Serverless v2, CloudFront, S3, ECR, NAT, CloudWatch, Cost Explorer
- OpenTofu
- GitHub Actions
- Python