Skip to content
$ lynuxpro
← All system designs

BEGINNER · 10 MIN · DEVOPS · SRE · PLATFORM · MLOPS

A highly available web app on AWS

The classic starter design: load balancer, app servers in two zones, a database with a standby, cache and object storage.

Peak load
200 req/s
Availability target
99.9%
RTO: back up within
1 hour (region)
RPO: data you can lose
5 min

← Swipe sideways to see the whole diagram →

ClientEdge / networkServiceData storeasync / background

The question

"Design the infrastructure for a normal web app (say an online store) so it stays up if one server or one data center fails."

Requirements

  • Serve web pages and an API to users over HTTPS.
  • Survive one server dying and one Availability Zone (AZ, a separate data center) going down.
  • Handle traffic going up and down during the day.
  • Keep data safe: backups and no single database server.

Quick numbers

ItemAssumptionResult
Daily users100,000about 1 request per second per 1,000 users at peak
Peak traffic10x average~200 requests per second
One app serverhandles ~100 req/s2 needed at peak, run 4 (2 per AZ) for safety

How it works

  1. Users load images, CSS and JavaScript from a CDN (CloudFront), close to them.
  2. API and page requests go to an Application Load Balancer in public subnets. It ends HTTPS and checks which servers are healthy.
  3. App servers run in private subnets in two AZs inside an Auto Scaling group. Unhealthy servers are replaced automatically, and more are added when CPU or request count rises.
  4. Servers read hot data from Redis and everything else from the database (RDS Multi-AZ: a primary plus a standby in another AZ).
  5. Uploads go to S3, not the servers' disks, so any server can be replaced at any time.
  6. A read replica takes reporting queries off the primary.

Remember it: keep servers stateless. Anything a user must not lose lives in the database, cache or S3, so servers are cattle, not pets.

Key decisions

DecisionChoiceWhy
Where state livesDB, Redis, S3servers can be killed and replaced freely
Networkpublic subnets only for the load balancerservers and DB are not reachable from the internet
ScalingAuto Scaling on request countfollows real load better than CPU alone
Database HAMulti-AZ standbyautomatic failover in about a minute

What breaks and how it heals

  • A server dies: health checks fail, the load balancer stops sending traffic, Auto Scaling starts a new one.
  • An AZ goes down: the other AZ keeps serving; the database fails over to the standby.
  • A bad deploy: roll out gradually (rolling or blue-green) so you can roll back before everyone is hit.
  • Database overloaded: add caching and read replicas first, then bigger instances, then split data.

Making it bigger

  • Put a WAF in front for attacks and bots.
  • Move to containers (ECS/EKS) when you have many services.
  • Add a queue (SQS) for slow work like emails and image resizing.

High availability and disaster recovery

TargetNumberHow it is met
Availability99.9% = at most 43 minutes down per month2 AZs for every layer, health checks, Auto Scaling
One server diesusers notice nothingload balancer stops sending traffic within ~10-30 s; Auto Scaling replaces it in ~3-5 min
One AZ fails~1-2 min of errors on writesRDS Multi-AZ fails over to the standby in about 60-120 s; no data lost (synchronous copy)
Whole region fails (DR)RTO 1 hour, RPO 5 minutespilot light in a second region: images copied, a cross-region read replica, Route 53 failover
Backupspoint-in-time restore to any second in the last 7-35 daysRDS automated backups; S3 versioning + cross-region replication

The four classic DR strategies, cheapest to most expensive:

StrategyWhat runs in the DR regionTypical RTOTypical RPOExtra cost
Backup and restorenothing, only backupshours (4-24 h)hourslowest
Pilot lightthe database replica only~1 hourminuteslow
Warm standbya small copy of everythingminutesseconds-minutesmedium
Multi-site active-activefull capacity serving trafficnear zeronear zero~2x

Remember it: RTO = how long until you are back. RPO = how much data you can lose. Pick them with the business, then choose the cheapest strategy that meets them.

Test it: restore a backup every month and run a DR failover game day every quarter. A backup you never restored is a hope, not a plan.

What interviewers listen for

  • You remove single points of failure at every layer.
  • You explain stateless servers and where state goes.
  • You mention health checks, Auto Scaling, backups and private subnets.