
Your platform grows and heals
Course 5 · Today ECS replaces and adds containers for you, and you write your own autoscaler
Today
| When | What | Where |
|---|---|---|
| 0:00 | HA vs scalability, load balancing, Auto Scaling, target tracking under the hood | Lecture |
| 0:30 | Multi-AZ, multi-region, Route 53, caching and CloudFront | Lecture |
| 0:50 | Containers, serverless, event-driven, microservices, platform 3.0 | Lecture |
| 1:30 | M4: two containers, the kill drill | Project |
| 2:05 | M4: your own autoscaler, load it both ways | Project |
| 2:55 | M4: CloudFront over your status page | Project |
| 3:10 | Your EPITA idea, designed in NOTES.md | Project |
| 3:45 | Check M4, commit | Project |
Staying up is not keeping up

High availability
The service stays up when one piece breaks

Scalability
It keeps up when more people show up
A bakery staying open when a cashier is sick, versus serving a hundred people at once.
A bigger server, or more of them?

Scale up
A bigger server. No code change, but a ceiling and a restart on every resize

Scale out
More servers behind a load balancer. No real ceiling, availability for free, the app must run as several copies
Scaling out is what the cloud is good at, and it only works if your servers are disposable.
The ALB hides a sick server, the ASG gets rid of it
| Load balancer check | Auto Scaling check (type ELB) | |
|---|---|---|
| Who decides | The ALB | The ASG, trusting the ALB |
| When a server fails | Visitors stop going to it | It's thrown away and replaced |
| Fixes the problem? | No, it walks around it | Yes, a fresh server takes its place |
Keep /health shallow. Deep checks belong in monitoring, where they raise an alarm.
What an Auto Scaling group needs
A launch templateThe recipe for one server: AMI, size, security group, instance profile, user data
Three numbersminnever fewer,maxnever more (your cost ceiling),desiredright now
Subnets in different AZsOne data center goes dark, the other half keeps running
A scaling policyTarget tracking: "keep average CPU around 50%" and AWS adds or removes servers

Your platform already works this way
Your servers have to be stateless
The group can terminate any server at any time. No uploads on disk, no sessions in memory, no SQLite file. State goes to RDS, S3 or a cache.
One building down, or the whole city?

Multi-AZ
The normal setup for anything real. RDS keeps a twin in another AZ, switches in a couple of minutes, same address

Multi-region
Data copied hundreds of km away, DNS sends users to the right place, the whole stack exists twice
RDS Multi-AZ means paying for two databases to use one, like a spare tire.

Write it in your project justification
Your database is your single point of failure
It's single-AZ. If its AZ goes down, every container returns errors.

At Alan, prod runs in Frankfurt across several AZs. Backups go to Paris and to a separate AWS account: if a stolen password can delete the backups, you have no backups.
DNS that picks the answer
| Policy | What it does | For your platform |
|---|---|---|
| Simple | One name, one answer | app.example.com to your ALB |
| Failover | Main while healthy, backup otherwise | Frankfurt ALB, then a "we'll be back" page on S3 |
| Latency | Fastest region for this user | Montreal to ca-central-1, Paris to eu-west-3 |
| Geolocation | By country or continent | French users to the EU stack, for data residency |
| Weighted | Split by percentage | 90% current version, 10% new (a canary) |
Latency is about speed, geolocation is about rules. Same user, different answers.
CloudFront, corner shops in every city
Cache hitThe edge has a fresh copy and answers in milliseconds.X-Cachetells you hit or miss
TTLHow long a copy stays fresh, 24 hours by default
InvalidationAsk CloudFront to throw its copies away early, after a deploy
HTTPS for freeThe padlock on a*.cloudfront.netname

You fix a typo in index.html at 10:00. When is everyone sure to see it?
The S3 website URL shows the fix right away. The CloudFront URL?

The database is the slow part, API CPU sits at 20%. Does your policy add servers?
And would more servers even help?

Don't run Kubernetes for a 3-container app
If you can't name the Kubernetes feature you need that ECS lacks, you don't need Kubernetes yet.
Who runs your containers?
| Docker on EC2 | ECS | EKS | |
|---|---|---|---|
| Who starts them | Your user data | AWS's orchestrator | Kubernetes, AWS runs its brain |
| Who looks after servers | You (ASG + AMI) | You, or nobody on Fargate | You, or nobody on Fargate |
| How hard to learn | Low | Medium | High |
| Cost before anything runs | None | None | $0.10 per hour per cluster, plus people's time |
| Sweet spot | 1 to 3 services, small team | Many services, AWS only | Many services and teams |
Fargate is often the best answer for a small team.

Alan runs Kubernetes
It pays off because of scale: many services, many engineers shipping every day, and an infra team that keeps it boring for everyone else.

3 services, 2 developers. Docker on EC2, ECS or EKS?
One sentence on why, one on what would make you switch.
Lambda is a taxi, not a rental car

Pay while it runs
It runs on an event, goes from zero copies to thousands, no server to patch

Cold start
No warm copy ready? It sets one up, up to a few seconds. Fine for background jobs

API Gateway
A managed front door for web APIs, forwarding requests to Lambda
Limits: 15 minutes per run, 128 MB to 10 GB of memory, 1,000 copies at once per region.
VM, container or function?
| VMs (EC2 + ASG) | Containers | Serverless | |
|---|---|---|---|
| What you ship | A disk image + boot script | A container image | A function |
| Scales in | Minutes | Seconds to a minute | Under a second to a few |
| Cost when idle | Running servers | Running containers | Zero |
| Cost when busy all day | Cheapest | Close to VMs | Often the most |
| Long jobs, open connections | Yes | Yes | No, 15 min max |
Spiky or rare work leans serverless, steady always-on work leans VMs or containers.
Pin the order, go back to the tables

SQS, a queue
One worker takes each message and deletes it. Workers down? Messages wait up to 14 days

SNS, pub/sub
A copy to every subscriber, stores nothing. You use it: your pager, and today your autoscaler
Together: one "new message" topic feeds a moderation queue and a stats queue, each at its own pace.

In a data center, you run the bus
IBM MQ or RabbitMQ, installed and patched by you, often behind an ESB. SQS and SNS are the same idea, with nobody on call for the broker.
Start with a monolith

Monolith
One app, one deploy, like yours

Microservices
Teams ship alone, but every call can fail over the network and a bug spans five services
Split a piece out only for a concrete reason. A small app stays a monolith, and you can defend that.
The platform 3.0 landscape
| Wave | The problem | On AWS |
|---|---|---|
| Big Data | Too much data, unplanned questions | S3 data lake, Glue or EMR clean, Athena or Redshift answer |
| IoT | Millions of tiny messages | MQTT to IoT Core, Kinesis streams, Lambda reacts |
| Social media | Feeds, friend graphs, viral spikes | SNS and SQS fan out to DynamoDB, Neptune holds the graph |
| SDN | Networks at the speed of code | You built one: your VPC, a template in course 6 |
Look at the arrows, not the logos. Same moves as your platform: queues, files in S3, managed scaling, pay per use.

Hands-on
Project M4: it survives, it scales, it has an edge
✅ ./checks/check.sh M4 all PASS, the scaler's log shows 2 -> 3 and 3 -> 2

One AZ goes down. When does your app keep working, and when does it die?
Your service spans two AZs, your database lives in one. Everything from today is on the course page.
