Automation and scaling
Running your app on AWS ECS Fargate: what it is and when it fits
Fargate runs your app in containers with no servers to patch. How a release works, what you still have to get right, and when a simpler option is the better choice.
By Mac Milan ·
Most business apps start on a single server. That works until the server needs patching, fills up, or goes down in the middle of a release. AWS ECS Fargate is the service we reach for most often to get a growing app past that stage.
What it is, in plain terms
A container is your app packaged together with everything it needs to run. ECS is the AWS service that starts those containers, keeps the right number of copies running, and replaces any copy that fails. Fargate supplies the computing power underneath, so there is no server for anyone to patch, resize or log in to.
- 01Code mergedA reviewed change is merged into the main branch.
- 02Image builtThe pipeline tests the app, packages it as a container image and stores it.
- 03New copies startECS starts the new version next to the one already running.
- 04Health checkedThe load balancer sends visitors only to copies that pass the health check.
- 05Old version retiredThe old copies stop. If the new ones fail, ECS goes back to the old version.
What you get
- Releases without downtime. The new version starts and proves it is healthy before the old one stops.
- Capacity that follows demand. Auto scaling adds copies when the app is busy and removes them when it is quiet. You are billed by the second for the CPU and memory you reserve.
- Failures that repair themselves. A copy that crashes is replaced automatically, and copies are spread across more than one AWS data centre.
- Less to secure. There is no server operating system to patch. Each service gets only the permissions it needs, and passwords and keys come from AWS Secrets Manager, not from the code.
What it does not do for you
Fargate removes the servers, not the design work. Someone still has to choose sensible CPU and memory sizes, write a health check that really tests the app, set the scaling rules and watch the bill. A health check that always answers "healthy" gives a release nothing to check, so a broken version goes live anyway.
Two more things to know. Your database is a separate service with its own sizing and backups. And a container that runs all night with no visitors costs the same as a busy one, so small services should be sized small.
When a simpler option is better
- A website with no login and no database. Static files on S3 and CloudFront cost less and have nothing to keep running. This website is built that way.
- Work that runs now and then. A nightly report or a form submission fits AWS Lambda, where you pay only while the code runs.
- A team that already runs Kubernetes well. Stay with what your team knows.
How we set it up
- Everything is written as code with Terraform, so each change is reviewed and can be repeated.
- Testing and live environments are separate, and a release passes through testing first.
- Logs, metrics and alarms are in place from the first release, not added after the first outage.
- After launch we compare the sizes and scaling rules with real usage and adjust them.
Related service: Automation and scaling