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:00HA vs scalability, load balancing, Auto Scaling, target tracking under the hoodLecture
0:30Multi-AZ, multi-region, Route 53, caching and CloudFrontLecture
0:50Containers, serverless, event-driven, microservices, platform 3.0Lecture
1:30M4: two containers, the kill drillProject
2:05M4: your own autoscaler, load it both waysProject
2:55M4: CloudFront over your status pageProject
3:10Your EPITA idea, designed in NOTES.mdProject
3:45Check M4, commitProject

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 decidesThe ALBThe ASG, trusting the ALB
When a server failsVisitors stop going to itIt's thrown away and replaced
Fixes the problem?No, it walks around itYes, 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 numbersmin never fewer, max never more (your cost ceiling), desired right 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.

Game time

A day on a small app

Open it on the course page

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.

Another account

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
SimpleOne name, one answerapp.example.com to your ALB
FailoverMain while healthy, backup otherwiseFrankfurt ALB, then a "we'll be back" page on S3
LatencyFastest region for this userMontreal to ca-central-1, Paris to eu-west-3
GeolocationBy country or continentFrench users to the EU stack, for data residency
WeightedSplit by percentage90% 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-Cache tells 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.net name

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?

Game time

Corner shop cache

Open it on the course page

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 themYour user dataAWS's orchestratorKubernetes, AWS runs its brain
Who looks after serversYou (ASG + AMI)You, or nobody on FargateYou, or nobody on Fargate
How hard to learnLowMediumHigh
Cost before anything runsNoneNone$0.10 per hour per cluster, plus people's time
Sweet spot1 to 3 services, small teamMany services, AWS onlyMany 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 shipA disk image + boot scriptA container imageA function
Scales inMinutesSeconds to a minuteUnder a second to a few
Cost when idleRunning serversRunning containersZero
Cost when busy all dayCheapestClose to VMsOften the most
Long jobs, open connectionsYesYesNo, 15 min max

Spiky or rare work leans serverless, steady always-on work leans VMs or containers.

Game time

Pick for your platform

Open it on the course page

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.

Game time

The burst

Open it on the course page

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 DataToo much data, unplanned questionsS3 data lake, Glue or EMR clean, Athena or Redshift answer
IoTMillions of tiny messagesMQTT to IoT Core, Kinesis streams, Lambda reacts
Social mediaFeeds, friend graphs, viral spikesSNS and SQS fan out to DynamoDB, Neptune holds the graph
SDNNetworks at the speed of codeYou 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

Steps on the course page

Game time

Today's quiz

Open it on the course page

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.