Course · 12

How do you run servers, networks, logins and files on AWS?

This page covers the AWS building blocks that show up in almost every design interview: where AWS runs, servers (EC2), scaling, load balancers, containers, Lambda, private networks (VPC), DNS, a CDN, logins and permissions (IAM), and file storage (S3). Every number was checked on docs.aws.amazon.com on 2026-10-25.

TL;DR

AWS is a set of rented building blocks: you spread servers across Availability Zones, put them in a private network, give them roles instead of passwords, and keep files in S3.

  • A Region is one city-area. It holds several Availability Zones (AZs): separate data centers with their own power. Spread across AZs to survive one failing.
  • Compute goes from most control to least: EC2 servers → containers (ECS, EKS, Fargate) → Lambda functions (max 15 min per run, up to 10,240 MB memory).
  • A VPC is your private network. Public subnets route to an internet gateway. Private subnets reach out through a NAT gateway, which charges per GB.
  • IAM: give code a role, which hands out short-lived keys. Never bake long-lived keys into servers.
  • S3 is designed for 99.999999999% durability and has had strong read-after-write consistency since December 2020.
34
Regions in the docs table for a normal AWS account
11nines
S3 designed durability, 99.999999999% a year
900s
Lambda max timeout for normal functions
5
IP addresses AWS keeps in every subnet

—Words you need

Each jargon word once, in plain words glossary

Region
A geographic area, like Mumbai, with several separate data centers.
Availability Zone (AZ)
One or more data centers in a Region, with separate power.
Edge location
A small AWS site near users that caches content.
EC2 instance
A virtual server you rent by the second.
AMI
A saved disk image you start servers from.
EBS
A network disk that lives on after the server stops.
Auto Scaling group
A fleet that adds or removes servers to match load.
Load balancer
A front door that spreads requests over healthy servers.
Cold start
Extra delay when Lambda must build a fresh environment first.
VPC
Your own private, isolated network inside AWS.
Subnet
A slice of the VPC's addresses, inside one AZ.
CIDR
Address range notation; /16 means 65,536 addresses.
NAT gateway
Lets private servers call out; blocks calls coming in.
Security group
A firewall on each server that remembers replies (stateful).
IAM role
A set of permissions that code borrows with temporary keys.
STS
The AWS service that hands out those temporary keys.

Foundations

01Regions, Availability Zones, edge locations

Where AWS physically runs, and why you spread across AZs core

A Region is a place in the world, such as us-east-1 (N. Virginia). Inside it are Availability Zones. An AZ is one or more data centers with their own power, network and cooling. AZs in a Region are linked by fast private networks. So you can copy data between them with low delay.

Edge locations are much smaller sites in many more cities. CloudFront (the AWS CDN, a cache close to users) runs there. They do not run your servers.

Region, Availability Zones and an edge location A user request goes to a nearby edge location; on a cache miss it goes to the Region, which holds three separate Availability Zones. REGION · US-EAST-1 REQUEST ON CACHE MISS Your userbrowser Edge locationCloudFront POP AZ a1+ data centers AZ bown power, net AZ c1+ data centers LEGEND Your user Edge location (cache) Availability Zone
Edge locations sit near users; Regions hold your servers, split into separate AZs.
In everyday words
A Region is a city. AZs are separate buildings in that city, each with its own power line. Edge locations are corner shops that keep copies of popular items.
Actually
The AWS docs define an AZ as "one or more discrete data centers, each with redundant power, networking, and connectivity, housed in separate facilities". The S3 docs add that AZs are "many kilometers" apart but "all are within 100 km (60 miles) of each other". The Regions docs page lists 34 Regions for a normal AWS account. Most show 3 AZs; us-east-1 shows 6. The marketing page counts differently: 39 geographic Regions, 124 AZs and 750+ CloudFront POPs. It includes Regions outside the standard account (for example China and GovCloud), so the two numbers do not clash. Checked 2026-10-25: AWS Regions, Global infrastructure.

Design for "one AZ dies": run at least two copies of everything in two AZs.

Source: AWS overview: global infrastructure · S3 data protection (AZ distance) · Regions table

02Who secures what: the shared responsibility model

AWS secures the cloud; you secure what you put in it interview favourite

AWS calls this "security of the cloud" versus "security in the cloud". AWS guards buildings, hardware, and the virtualization layer (the software that splits one machine into many). You guard your data, your settings and your code. The line moves with the service. The more managed the service, the more AWS does.

LayerEC2 (you rent a server)Lambda / S3 / DynamoDB (managed)
Buildings, hardware, networkAWSAWS
Host OS and virtualizationAWSAWS
Guest OS patchesYouAWS
Your app codeYouYou
Firewall rules, IAM permissionsYouYou
Data and encryption choicesYouYou
In everyday words
A landlord fixes the roof and the wiring. You lock your own door and decide who gets a key.
Actually
AWS's page says that for EC2 the customer manages "the guest operating system (including updates and security patches)", the apps and the security group setup. For S3 and DynamoDB, AWS runs the infrastructure and the platform; you manage data, encryption and IAM permissions. Source: AWS shared responsibility model.

"Is it AWS's fault?" Almost never for a leaked bucket or an open port: those settings are yours.

Source: aws.amazon.com/compliance/shared-responsibility-model

Compute

03EC2: renting servers

Instance families, ways to pay, and the two kinds of disk core

An EC2 instance is a virtual server. Its type name tells you its shape. In c7gn.xlarge, c is the family (compute-heavy), 7 the generation, gn extra options (Graviton CPU, more network), and xlarge the size.

LetterFamilyGood for
MGeneral purposeWeb apps, balanced work
CCompute optimizedCPU-heavy work, encoding, game servers
R, XMemory optimized / memory intensiveCaches, in-memory databases
TBurstable performanceLow steady load with short spikes
I, DStorage optimized / dense storageFast local disks, big data
P, GGPU accelerated / graphicsMachine learning, rendering

You start an instance from an AMI (Amazon Machine Image: a saved disk image with the OS and your software). Baking your app into an AMI makes new servers start faster.

Ways to pay

Biggest discount off On-Demand, by way of paying

"Up to" numbers. Hover a bar for the source. Spot is a marketing-page claim, not a docs number.

Spot can be taken back
90%
Savings Plans / Reserved 1 or 3 yr
72%
On-Demand
0%
Show the full table
OptionHow it worksMax discountCatch
On-DemandPay by the second, no promise0%Most expensive per hour
Savings PlansPromise a dollar amount per hour for 1 or 3 years72%You pay even if unused
Reserved InstancesPromise a specific instance type and Region for 1 or 3 years72%Less flexible; AWS now recommends Savings Plans
SpotSpare capacity at a changing price90%AWS can take it back with a 2-minute warning

Two kinds of disk

QuestionEBS volumeInstance store
Where is it?A separate storage device you attachDisks physically in the host computer
Survives stop or terminate?Yes, it lives on independentlyNo, data is erased on stop, hibernate or terminate
Survives reboot?YesYes
AZ ruleMust be in the same AZ as the instancePart of the instance
Use forOS disk, databasesCaches, scratch files, buffers
In everyday words
On-Demand is a taxi. A Savings Plan is a monthly pass. Spot is a cheap standby seat you lose if a paying passenger shows up.
Actually
Docs (checked 2026-10-25): On-Demand is billed "by the second". Savings Plans and Reserved Instances are "a term of 1 or 3 years", with savings "up to 72%". A Spot interruption notice is "a warning that is issued two minutes before Amazon EC2 stops or terminates your Spot Instance". Instance store data "does not persist if the instance is stopped, hibernated, or terminated". EBS volumes "persist independently from the running life of an EC2 instance" and "the volume and instance must be in the same Availability Zone". EBS is copied across several servers inside one AZ; io2 Block Express is designed for 99.999% durability, other types 99.8–99.9%. Sources: purchasing options, Spot notices, instance store lifetime, EBS volumes.

Steady base load on Savings Plans, spikes on On-Demand, and retry-safe batch jobs on Spot.

Source: instance type names · Savings Plans · Reserved Instances · Spot (up to 90%, marketing page) · What is EBS

04Auto Scaling groups and load balancers

Add servers when busy, remove them when quiet, and send traffic only to healthy ones core

An Auto Scaling group (ASG) keeps a fleet between a minimum and a maximum size. It starts servers from a launch template: a saved recipe with the AMI, instance type, key pair and security groups. A scaling policy decides when to change the size.

How an Auto Scaling group reacts to load and failures A CloudWatch metric triggers a scaling policy that adjusts the group; the group reads the launch template and launches instances; the load balancer health-checks instances and reports unhealthy ones so the group replaces them. ALARM ADJUST READS LAUNCH CHECKS UNHEALTHY Load metricCloudWatch Scaling policytarget tracking Scaling groupmin / max size Load balancerhealth checks New instancesEC2 Launch templateAMI + type LEGEND Scaling group Step Saved recipe AWS service
Two loops: load changes the size, and failed health checks replace servers.
Policy typeWhat it doesUse when
Target trackingKeeps a metric near a target, like a thermostat (for example average CPU at 50%)Default choice; AWS "strongly recommends" it
Step scalingAdds more servers the bigger the alarm breachYou need different jumps for small and big spikes
Simple scalingOne fixed change, then a cooldown waitOld setups; prefer the two above
ScheduledChanges min, max or desired size at set times (cron)Known peaks, like 9 a.m. on weekdays

Load balancers: three kinds

TypeOSI layerRoutes byBest for
Application (ALB)Layer 7 (HTTP)Path, host, headers, method, query; can call LambdaWeb apps and microservices
Network (NLB)Layer 4 (TCP, UDP, TLS, QUIC)Flow hash; one TCP connection sticks to one targetMillions of requests per second, static IP per AZ
Gateway (GWLB)Layer 3 (IP packets)5-tuple flow hash, GENEVE on port 6081Firewalls and traffic inspection boxes

A target group is the list of servers (or IPs, or Lambda functions) behind a load balancer rule. Health checks are set per target group.

Cross-zone load balancing decides if a load balancer node may send traffic to servers in other AZs. The docs example has 2 servers in AZ A and 8 in AZ B, with each AZ's node getting half the traffic:

Share of all traffic each single server gets

AWS docs example: 2 targets in AZ A, 8 in AZ B. Hover for details.

Cross-zone off, server in AZ A
25%
Cross-zone on, any server
10%
Cross-zone off, server in AZ B
6.25%
Show the full table
SettingPer server in AZ APer server in AZ B
Cross-zone on10%10%
Cross-zone off25%6.25%
In everyday words
A shop manager watches the queue. When it gets long, she opens more tills from the same template. The door greeter sends shoppers only to tills that are open.
Actually
Docs (checked 2026-10-25): with ALB, cross-zone is "always enabled at the load balancer level" (you can turn it off per target group). For NLB and GWLB it is "disabled by default". An ALB needs at least two AZs. The load balancer DNS name has a TTL of 60 seconds so IPs can change quickly. The ASG health check grace period defaults to 300 seconds in the console but 0 from the CLI or SDK. When a scaling policy runs, the ASG never goes outside its min and max. Sources: How ELB works, grace period, dynamic scaling.

Put an ALB in front of an ASG spread over 2+ AZs, with ELB health checks turned on, so dead servers get replaced.

Source: launch templates · scheduled scaling · ASG health checks · ALB · NLB · GWLB

05Containers (ECS, EKS, Fargate) and Lambda

Less server work as you go right: EC2 → containers → functions core

A container packs your app with everything it needs, so it runs the same anywhere. AWS gives two ways to run many containers, and two places to run them.

ServiceWhat it isPick it when
ECSAWS's own container scheduler. You write a task definition (the blueprint); it runs tasks and servicesYou want simple, AWS-native containers
EKSManaged Kubernetes. AWS runs the Kubernetes control planeYour team already uses Kubernetes, or needs to move between clouds
FargateServerless capacity for ECS or EKS: no servers to manage or patchYou do not want to manage the EC2 hosts under the containers
EC2 capacityContainers on servers you choose and manageYou need special hardware (GPU) or the lowest price at large scale

Lambda: functions that run on events

Lambda runs your code when something happens: an HTTP call, a file landing in S3, a queue message. You pay only while it runs. Each running copy lives in an execution environment (a small isolated sandbox). Concurrency is how many copies run at the same moment.

Limit (checked 2026-10-25)Value
Max run time per invocation900 s (15 min)
Memory128–10,240 MB
CPUgrows with memory; 1,769 MB = 1 vCPU
Default concurrency per Region1,000
Sync request / response payload6 MB each
/tmp disk512–10,240 MB
Init phase limit (normal functions)10 s
Scale-up rate per function1,000 environments every 10 s

A cold start happens when no warm environment is free. Lambda must download your code, start the runtime and run your setup code first. After the call, Lambda freezes the environment and reuses it ("warm start").

In everyday words
EC2 is owning a car. Containers on Fargate are a rental car you just drive. Lambda is a taxi: it shows up per trip, but the first one of the morning takes longer to arrive.
Actually
Lambda docs: cold starts "typically occur in under 1% of invocations" and last "from under 100 ms to over 1 second". Concurrency = average requests per second × average duration in seconds (5,000 rps × 0.2 s = 1,000). Fixes: provisioned concurrency keeps environments pre-initialized (extra cost); SnapStart restores from a saved snapshot. Reserved concurrency is different: it caps a function and guarantees it a slice of the account pool. Lambda always keeps 100 units unreserved. Exceptions to the 15-minute cap exist: Lambda Managed Instances allow up to 90 min for async calls, and durable functions can run for up to a year. Sources: Lambda quotas, execution environment lifecycle, Lambda concurrency.

Short, spiky, event-driven work → Lambda. Long-running or steady services → containers on Fargate or EC2.

Source: What is ECS · What is EKS · Lambda quotas

Networking

06VPC: your private network

CIDR ranges, public and private subnets, internet gateway, NAT gateway, route tables interview favourite

A VPC (virtual private cloud) is a network only you use. You give it an address range in CIDR notation, for example 10.0.0.0/16. The number after the slash says how many bits are fixed. /16 leaves 16 free bits, so 65,536 addresses.

You cut the VPC into subnets. Each subnet lives in exactly one AZ. A route table on each subnet says where traffic may go. That route table, and nothing else, makes a subnet "public" or "private".

A VPC with a public and a private subnet Internet traffic enters through the internet gateway to a load balancer in the public subnet, which calls an app server in the private subnet; the app server reaches the internet only outbound through a NAT gateway in the public subnet, and talks to a database in the private subnet. VPC 10.0.0.0/16 PUBLIC SUBNET PRIVATE SUBNET HTTP TO INTERNET SQL Internetusers GatewayIGW Load balancerALB NAT gatewayoutbound only App serverEC2 DatabaseRDS LEGEND NAT gateway Server or router Database Outside VPC
Requests come in through the gateway to the load balancer; private servers go out only through NAT.
PieceWhat it doesKey fact
Internet gateway (IGW)Connects the VPC to the internetA subnet is public only if its route table has a route to an IGW
NAT gatewayLets private servers start outbound connectionsOutsiders cannot start a connection in. Charged per hour and per GB
Route tableRules: "traffic for this range goes to that target"Most specific match wins (longest prefix)
Subnet sizeBetween /28 and /16AWS keeps 5 addresses per subnet
In everyday words
The VPC is a gated housing estate. The public subnet is the street with the front gate. The private subnet is the back lane with no gate: residents can post letters out through the NAT post office, but strangers cannot walk in.
Actually
Docs (checked 2026-10-25): in a 10.0.0.0/24 subnet AWS reserves .0 (network), .1 (VPC router), .2 (DNS), .3 (future use) and .255 (broadcast). A standard NAT gateway is "created in a specific Availability Zone". If its AZ goes down, "resources in the other Availability Zones lose internet access", so create one per AZ. It starts at 5 Gbps and scales to 100 Gbps. New: a regional NAT gateway spreads across AZs by itself and needs no public subnet. It can take up to 60 min to expand to a new AZ. Sources: subnet sizing, NAT gateway basics, regional NAT gateways, subnet types.

Only load balancers (and NAT) live in public subnets. Servers and databases live in private subnets.

Source: Subnets for your VPC · NAT gateways · Subnet CIDR blocks

07Firewalls, endpoints, and joining VPCs

Security groups vs NACLs, VPC endpoints, peering vs Transit Gateway interview favourite

QuestionSecurity groupNetwork ACL
Works onEach instance (its network card)A whole subnet
Rule typesAllow onlyAllow and deny
How rules are checkedAll rules, then decideIn number order; first match wins
Reply trafficAllowed automatically (stateful)Must be allowed by its own rule (stateless)
Typical useMain firewallExtra guard rail, such as blocking one bad IP range

Stateful means the firewall remembers a conversation, so the reply gets in without a rule. Stateless means each packet is judged alone, so you must open the reply ports too.

VPC endpoints: reach AWS services without the internet

Endpoint typeWorks withHowCost
Gateway endpointS3 and DynamoDB onlyA route in your route tableNo extra charge
Interface endpoint (PrivateLink)Many AWS services and your own servicesA network card with a private IP in your subnetBilled

Joining VPCs

VPC peering is not transitive VPC A is peered with VPC B and with VPC C, but B cannot reach C through A; that needs its own peering or a transit gateway. PEERED PEERED NO TRANSIT VPC B10.1.0.0/16 VPC A10.0.0.0/16 VPC C10.2.0.0/16 LEGEND VPC Peering link No route (not transitive)
Peering is one-to-one. B to C needs its own link, or a hub.
QuestionVPC peeringTransit Gateway
ShapeOne-to-one links (a mesh)A regional hub; every VPC attaches once
Transitive routing?NoYes, through its route tables
On-premises (VPN, Direct Connect)Cannot share a peer's VPN or gatewayAttach VPN and Direct Connect gateways
Overlapping CIDRsNot allowedPlan non-overlapping ranges anyway
CostPay for data across AZs or RegionsPer attachment per hour + per GB processed
Pick when2–3 VPCsMany VPCs, or VPCs plus an office network
In everyday words
Peering is a private footpath between two houses. Your neighbour's footpath does not let you into the third house. A Transit Gateway is a bus station every house connects to.
Actually
VPC docs: security groups are stateful and allow-only; network ACLs are stateless and evaluate rules "in ascending order until a match". Peering "does not support transitive peering relationships", and you "cannot create a VPC peering connection between VPCs that have matching or overlapping" CIDR blocks. A peer cannot use your IGW, NAT, VPN or gateway endpoint ("edge to edge routing"). Gateway endpoints: "There is no additional charge". Transit Gateway: "charged hourly for each attachment" plus traffic processed. Sources: SG vs NACL, peering basics, gateway endpoints, Transit Gateway.

Add an S3 gateway endpoint to every VPC: free, and S3 traffic stops paying NAT per-GB fees.

Source: PrivateLink concepts · VPC peering · Transit Gateway

08Route 53 and CloudFront

DNS that can route by health, weight, delay and place; a CDN at the edge core

Route 53 is AWS's DNS (the internet's phone book: name → IP). Each record has a routing policy that decides which answer to give.

PolicyAnswer it givesExample use
SimpleOne fixed resourceA single web server
WeightedSplits by the share you setSend 10% to a new version (canary)
LatencyThe Region with the lowest delay for this userSame app in Mumbai and Frankfurt
FailoverPrimary while healthy, else secondaryActive-passive disaster recovery
GeolocationBy the user's locationCountry rules, local language
GeoproximityBy distance to your resources, with a bias you can shiftMove load between Regions
Multivalue answerUp to 8 healthy records at randomSimple client-side spreading
IP-basedBy the caller's IP rangeRoute an ISP's users to a set endpoint

CloudFront is the AWS CDN. A user's request goes to the edge location with the lowest delay. If the file is cached there, it is returned at once. If not, CloudFront fetches it from your origin (S3, a load balancer, any HTTP server).

In everyday words
Route 53 is a receptionist who can say "go to the nearest branch" or "that branch is closed, use this one". CloudFront is a chain of local warehouses stocked with copies of your goods.
Actually
CloudFront docs: by default a file stays in an edge cache for 24 hours; the minimum is 0 seconds and there is no maximum. Data from AWS origins (S3, ELB, API Gateway) to CloudFront "is always free"; you pay for data out to viewers and for requests. Route 53 docs list eight routing policies. Multivalue answers return "up to eight healthy records". Sources: What is CloudFront, Route 53 routing policies.

Latency or failover records in Route 53 plus CloudFront in front give you a fast, multi-Region front door.

Source: Choosing a routing policy · CloudFront introduction

Identity and storage

09IAM: users, groups, roles, policies

Who may do what, and why code should borrow keys, not own them interview favourite

ThingWhat it isCredentials
IAM userOne person or app with its own identityLong-lived password or access keys
GroupA set of users that share policiesNone of its own
RoleA set of permissions anyone trusted may borrowTemporary keys from STS
PolicyA JSON document: allow or deny actions on resourcesAttached to a user, group, role or resource
Instance profileThe holder that passes one role to an EC2 instanceThe SDK reads temporary keys from instance metadata
Identity policy from the IAM docs · read and write objects in one bucket
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "ListObjectsInBucket",
      "Effect": "Allow",
      "Action": ["s3:ListBucket"],
      "Resource": ["arn:aws:s3:::bucket-name"]        // the bucket itself
    },
    {
      "Sid": "AllObjectActions",
      "Effect": "Allow",
      "Action": "s3:*Object",                          // GetObject, PutObject, DeleteObject...
      "Resource": ["arn:aws:s3:::bucket-name/*"]      // objects inside it
    }
  ]
}

Least privilege means giving only the actions a task needs, on only the resources it needs. The policy above is a good start: one bucket, not "Resource": "*".

Assuming a role, then using the temporary keys Your app calls STS AssumeRole, STS checks the role's trust policy and returns temporary credentials, then the app calls S3 GetObject with them, and S3 checks IAM permissions before returning the object. ASSUMEROLE TRUST POLICY TEMP KEYS GETOBJECT IAM CHECK OBJECT Your apphas a role AWS STStoken service Amazon S3bucket LEGEND Call Reply Key reply: temporary keys
Time runs downward. The keys expire, so a leaked copy stops working soon.

A role has two policies. The trust policy says who may assume it. The permissions policy says what it may do. On EC2 you never call STS yourself: the instance profile does it, and the SDK picks up the keys from instance metadata.

In everyday words
An IAM user is a staff ID card you carry forever. A role is a visitor badge from reception: you show who you are, get a badge for one floor, and it stops working at the end of the day.
Actually
STS AssumeRole returns "an access key ID, a secret access key, and a security token". DurationSeconds runs from 900 s (15 min) up to the role's max session, which can be set from 1 to 12 hours; the default is 3,600 s. Role chaining (a role assuming another role) caps the session at one hour. Policy evaluation: everything starts denied, an explicit Allow is needed, and "an explicit deny in either of these policies overrides the allow". An instance profile "can contain only one IAM role". IAM best practices say humans should use federation with temporary credentials, and workloads should use roles. Sources: AssumeRole API, policy evaluation logic, instance profiles, IAM best practices.

Code gets a role, never an access key in a config file. Explicit deny always wins.

Source: IAM example: read/write one bucket · IAM best practices

10S3: object storage

Storage classes, durability, consistency, versioning, lifecycle, pre-signed URLs, encryption deep dive

S3 stores objects (a file plus metadata) in buckets. Each object has a key, its full name like photos/puppy.jpg. There are no real folders: photos/ is just a prefix of the key.

Storage classes

All classes in the docs table are designed for 99.999999999% durability, except the old Reduced Redundancy class. They differ in price, availability, retrieval time, and the minimum storage duration (you pay at least this many days even if you delete sooner).

Minimum days you pay for, by storage class

From the S3 storage class comparison table. Hover for availability and AZ count.

Glacier Deep Archive
180
Glacier Flexible Retrieval
90
Glacier Instant Retrieval
90
Standard-IA
30
One Zone-IA
30
Intelligent-Tiering
0
Standard
0
Show the full table
ClassForAvailabilityAZsMin days
StandardHot data, accessed often99.99%3+0
Intelligent-TieringUnknown or changing access99.9%3+0
Standard-IARead about once a month99.9%3+30
One Zone-IARe-creatable, rarely read99.5%130
Express One ZoneSingle-digit ms access99.95%10
Glacier Instant RetrievalArchive, read once a quarter, ms access99.9%3+90
Glacier Flexible RetrievalArchive, minutes to hours to restore99.99%3+90
Glacier Deep ArchiveArchive, hours to restore99.99%3+180

Features you will be asked about

FeatureWhat it doesKey fact (checked 2026-10-25)
ConsistencyA read after a successful write sees the new dataStrong read-after-write for PUT and DELETE, all Regions, since Dec 2020. Bucket settings are still eventually consistent
VersioningKeeps every version; a delete adds a "delete marker"Once on, a bucket can be suspended but never returns to unversioned
Lifecycle rulesTransition to a cheaper class, or expire (delete)Rules apply to existing objects too
Pre-signed URLA link that lets anyone GET or PUT one object for a whileUp to 7 days with SigV4 and IAM user keys; never longer than the creating credentials
Encryption at restSSE-S3 (default), SSE-KMS, DSSE-KMS, SSE-CSSE-S3 on all new uploads since 5 Jan 2023. SSE-C is off by default for new buckets since April 2026
Object sizeSingle PUT, or multipart upload5 GB per PUT; multipart up to 50 TB
Request rateScales per key prefixAt least 3,500 writes and 5,500 reads per second per prefix

S3 as a static website, behind CloudFront

S3 can serve a static site (HTML, CSS, JS). But the S3 website endpoint is HTTP only. For HTTPS, put CloudFront in front. Keep the bucket private and let only CloudFront read it, using Origin Access Control (OAC).

In everyday words
S3 is a huge warehouse of labelled boxes. Storage classes are shelves: the front shelves cost more but are quick to reach; the back store is cheap but you must book a pickup. A pre-signed URL is a one-time pickup slip that expires.
Actually
S3 docs: Standard and most classes "redundantly store objects on multiple devices across a minimum of three Availability Zones" and are "designed to provide 99.999999999% durability and 99.99% availability of objects over a given year". Consistency: "Any read (GET or LIST request) that is initiated following the receipt of a successful PUT response will return the data written". Two writers to the same key at once: "the request with the latest timestamp wins", and there is no atomic update across keys. The launch post is dated December 2020. Website endpoints: "do not support HTTPS". CloudFront recommends OAC over the legacy OAI, because OAC supports SSE-KMS and all Regions. Sources: data protection, consistency model, Dec 2020 announcement, website endpoints, CloudFront OAC.

Upload directly from the browser with a pre-signed PUT URL, so big files never pass through your servers.

Source: storage classes · versioning · lifecycle · pre-signed URLs · encryption · uploading objects · performance

11Putting it together: a typical 3-tier web app

Web, app and data tiers across two AZs design

A 3-tier app splits into a front (web), a middle (app logic) and a back (database). On AWS the usual shape is below.

A typical 3-tier web app on AWS Users reach CloudFront, which serves static files from a private S3 bucket and sends dynamic calls to a load balancer in public subnets; the load balancer calls app servers in an Auto Scaling group in private subnets, which talk to an RDS Multi-AZ database. VPC PUBLIC PRIVATE STATIC SQL Usersbrowser CloudFrontCDN + HTTPS Load balancerALB App serversASG, 2+ AZs S3 bucketstatic files DatabaseRDS Multi-AZ LEGEND App tier (scales) Entry point Storage Users
Static files go CloudFront → S3; dynamic calls go CloudFront → ALB → app → database.
TierAWS piecesWhy this way
EdgeRoute 53 → CloudFront (with AWS WAF if needed)HTTPS, caching near users, one domain for static and dynamic
StaticPrivate S3 bucket + OACCheap, durable; bucket is never public
Web / appALB in public subnets → ASG in private subnets, 2+ AZsSurvives one AZ failing; scales with load
DataRDS Multi-AZ (or Aurora) in private subnets; cache in ElastiCacheStandby in another AZ; see page 13
OutboundNAT gateway per AZ (or regional NAT), S3 gateway endpointPatches and API calls go out; S3 traffic skips NAT fees
IdentityInstance profile role on the app serversNo keys on disk
In everyday words
A restaurant: the host at the door (CloudFront and the ALB), cooks in the kitchen (app servers), and the pantry in the back (database). Customers never walk into the kitchen.
Actually
Each piece above is backed by a docs fact on this page: ALB needs two or more AZs (section 04), a subnet is private when it has no route to an internet gateway (section 06), gateway endpoints for S3 have no extra charge (section 07), and CloudFront pulls from AWS origins for free (section 08). The Multi-AZ database details are on page 13. Source: How ELB works, subnet types.

In an interview, draw this first, then say how each box survives losing one AZ.

Source: sections 04–10 of this page · VPC infrastructure security

Practice

—When to use what

Situation → pick → why decision table

SituationPickWhy
Steady web service, team knows containersECS on Fargate behind an ALBNo servers to patch; ALB routes by path
Team already runs KubernetesEKSSame tools and manifests; AWS runs the control plane
Spiky event handler, each run under 15 minLambdaPay per run; scales to zero
Job longer than 15 minutesECS/Fargate task or EC2Lambda's normal cap is 900 s
Need a fixed IP or raw TCP/UDPNLBStatic IP per AZ, Layer 4
Route /api and /images to different servicesALBPath and host rules at Layer 7
Insert a third-party firewall in the pathGWLBBuilt for inspection appliances
Batch work that can restartSpot instancesUp to 90% cheaper (marketing page); 2-minute warning
Known 24/7 base loadSavings PlanUp to 72% off for a 1 or 3 year promise
Private servers must call the internetNAT gatewayOutbound only; no inbound
Private servers read S3 a lotS3 gateway endpointFree; avoids NAT per-GB charges
Connect 2–3 VPCsVPC peeringSimple, no hub to pay for
Connect many VPCs plus an officeTransit GatewayTransitive hub; VPN and Direct Connect attach
Users in many countriesCloudFront + Route 53 latency recordsEdge caching; nearest Region
Let a browser upload a 2 GB videoPre-signed PUT URL (multipart)Bypasses your servers
Logs you must keep 7 yearsS3 lifecycle → Glacier Deep ArchiveCheapest; 180-day minimum fits

—Common traps

Mistakes that cost money or uptime traps

Trap
One NAT gateway for all AZs

If missed: its AZ fails and every private server loses the internet.

Fix: one NAT per AZ, or a regional NAT gateway.

Trap
S3 traffic going through NAT

If missed: you pay NAT per-GB charges on every S3 read.

Fix: add the free S3 gateway endpoint.

Trap
Access keys in code or AMIs

If missed: keys leak in git and never expire.

Fix: instance profile role, temporary STS keys.

Trap
Data on instance store

If missed: a stop or terminate erases it.

Fix: EBS, S3 or a database for anything you need later.

Trap
NACL blocks reply traffic

If missed: requests go out, replies never come back.

Fix: NACLs are stateless; allow the return port range too.

Trap
Expecting peering to be transitive

If missed: VPC B cannot reach C through A.

Fix: direct peering B–C, or a Transit Gateway.

Trap
Overlapping CIDR ranges

If missed: two VPCs can never be peered.

Fix: plan unique ranges per VPC from day one.

Trap
ASG with EC2 checks only

If missed: a server whose app is hung stays "healthy".

Fix: turn on ELB health checks for the group.

Trap
Lambda for long jobs

If missed: hard stop at 900 s, half-done work.

Fix: split into steps, or use Fargate.

Trap
Public S3 website for HTTPS

If missed: website endpoints are HTTP only.

Fix: private bucket + CloudFront + OAC.

—Interview questions

20 questions, easy to design-level. Try first, then open the answer practice

What is the difference between a Region and an Availability Zone? easy
Show answer
A Region is a geographic area, like ap-south-1 (Mumbai). An AZ is one or more data centers inside it, with separate power, networking and connectivity. AZs are many kilometers apart but within 100 km, so you can replicate synchronously between them with low delay. Why it matters: an AZ is the unit of failure you design for. You run at least two copies in two AZs. A whole-Region outage is rarer; you design for that with multi-Region setups only when the business needs it, because it adds cost and data-consistency work. Number: the docs list 34 Regions for a normal account, most with 3 AZs.
Follow-up: what services are zonal vs regional? (EBS and a standard NAT gateway are zonal; S3 is regional.)
Explain the shared responsibility model with one example. easy
Show answer
AWS secures "of" the cloud: buildings, hardware, network, and the virtualization layer. The customer secures what is "in" the cloud: data, IAM, firewall rules, and on EC2 the guest OS patches. The line moves with the service: on Lambda or S3, AWS also runs the OS and platform, so you only own code, data and permissions. Example: an S3 bucket made public by mistake is the customer's problem, not AWS's. Another: an unpatched kernel on an EC2 instance is yours; an unpatched host under Lambda is AWS's.
On-Demand, Savings Plans, Reserved Instances, Spot: when do you use each? easy
Show answer
On-Demand: unpredictable or short-lived load; billed per second, no promise. Savings Plans: steady base load; you promise a dollar amount per hour for 1 or 3 years and save up to 72%. Reserved Instances save up to the same, but tie you to an instance type and Region; AWS now recommends Savings Plans. Spot: spare capacity, up to 90% off per AWS's marketing page, but AWS can take it back with a two-minute warning. So use Spot only for work that can stop and restart: batch, CI runners, stateless workers behind a queue. A good fleet mixes them: base on Savings Plans, peaks on On-Demand, retry-safe jobs on Spot.
EBS vs instance store: which one for a database? easy
Show answer
EBS. An EBS volume lives on independently of the instance, can be snapshotted, and is replicated across servers inside its AZ. Instance store is disks physically in the host; its data is erased when the instance stops, hibernates or terminates, and on disk failure. Instance store is faster and free with the instance, so it suits caches, scratch space and replicated data (for example a Cassandra node that has copies elsewhere). Watch out: an EBS volume must be in the same AZ as the instance, so it is not a cross-AZ failover by itself; use snapshots or database replication for that.
What makes a subnet public or private? easy
Show answer
Only its route table. A public subnet has a route (usually 0.0.0.0/0) to an internet gateway. A private subnet has no route to an internet gateway; it may route 0.0.0.0/0 to a NAT gateway to make outbound calls. An isolated subnet has no route out of the VPC at all. The name you give the subnet means nothing to AWS. Also needed for public access: the instance needs a public IP, and the security group must allow the traffic. Each subnet sits in exactly one AZ, and AWS reserves 5 addresses in each.
Security group vs network ACL? medium
Show answer
A security group is attached to each instance's network card, allows only, checks all rules, and is stateful: if a request is allowed in, the reply goes out automatically. A network ACL is attached to a subnet, has allow and deny rules, checks them in number order until the first match, and is stateless: you must allow return traffic, usually the ephemeral port range, yourself. Security groups are the main tool; they can also reference other security groups (for example "allow port 5432 from the app tier's SG"), which IPs cannot do neatly. Use NACLs as a coarse extra layer, such as denying a known bad CIDR.
How do private instances download patches? What does that cost? medium
Show answer
Through a NAT gateway in a public subnet (or a regional NAT gateway, which needs no public subnet). The NAT lets instances start outbound connections but blocks inbound ones. Cost: an hourly charge plus a per-GB processing charge on everything that passes through it. Two traps: a standard NAT gateway lives in one AZ, so if that AZ fails, instances in other AZs lose internet access; create one per AZ. And S3 or DynamoDB traffic should go through a free gateway endpoint instead of the NAT. Capacity: 5 Gbps, scaling to 100 Gbps per NAT gateway.
ALB vs NLB vs GWLB: how do you choose? medium
Show answer
ALB works at Layer 7: it reads HTTP, so it can route by path, host, header, method or query, terminate TLS, authenticate users, and call Lambda. Use it for web apps and microservices. NLB works at Layer 4 (TCP, UDP, TLS, QUIC): it handles millions of requests per second, gives a static IP per AZ (optionally an Elastic IP), and keeps each TCP connection on one target. Use it for non-HTTP protocols, fixed IPs, or extreme throughput. GWLB works at Layer 3 and sends packets over GENEVE (port 6081) to virtual appliances such as firewalls. Note the defaults: cross-zone is always on for ALB, off by default for NLB and GWLB.
Target tracking vs step vs scheduled scaling? medium
Show answer
Target tracking works like a thermostat: you pick a metric and a target (for example average CPU 50%, or requests per target), and the ASG adds or removes servers to stay near it. AWS strongly recommends it; pick a metric that drops when you add capacity. Step scaling adds different amounts depending on how far an alarm is breached: plus 1 at 60% CPU, plus 4 at 90%. Scheduled scaling changes min, max or desired size at fixed times with cron, for known peaks. You can combine them; when several policies fire, the ASG picks the one giving the largest capacity. Add a warm-up and an ELB health check grace period so new servers are not killed while booting.
What is a Lambda cold start, and how do you reduce it? medium
Show answer
When no warm execution environment is free, Lambda must download the code, start the runtime and run your init code before the handler. AWS says this happens in under 1% of invocations and takes from under 100 ms to over a second. Fixes: keep the package small and import only what you need; do heavy setup (DB connections, SDK clients) outside the handler so warm calls reuse it; use provisioned concurrency to keep N environments pre-initialized (costs money); or SnapStart, which restores from a snapshot. Concurrency math: 5,000 rps × 0.2 s = 1,000 environments, the default account limit.
Reserved concurrency vs provisioned concurrency? medium
Show answer
Reserved concurrency carves out a fixed slice of the account's pool for one function. It is both a floor (others cannot take it) and a ceiling (the function cannot exceed it). It is free and great for protecting a downstream database: cap the function at 50 and the DB never sees more than 50 parallel connections from it. Provisioned concurrency pre-initializes environments to remove cold starts; it costs extra and can spill into unreserved capacity when exceeded. The two can be combined. Lambda always keeps 100 units unreserved for other functions.
ECS vs EKS vs Fargate? medium
Show answer
ECS and EKS are schedulers (they decide where containers run). ECS is AWS's own, simpler, with task definitions, tasks and services. EKS is managed Kubernetes: AWS runs the control plane; you get the Kubernetes API and ecosystem, with more moving parts. Fargate is not a scheduler but a capacity type: serverless compute under ECS or EKS, so you do not manage or patch EC2 hosts. Choose ECS on Fargate for a small team on AWS only; EKS if the team already runs Kubernetes or needs portability; EC2 capacity if you need GPUs, special instance types, or the lowest unit cost at very large scale.
VPC peering vs Transit Gateway? medium
Show answer
Peering is a one-to-one private link between two VPCs. It is not transitive: if A peers with B and with C, B still cannot reach C through A. Peers also cannot share each other's internet gateway, NAT, VPN or gateway endpoints, and CIDRs must not overlap. With N VPCs a full mesh needs N×(N−1)/2 links: 10 VPCs means 45 peerings. Transit Gateway is a regional hub: each VPC, VPN or Direct Connect gateway attaches once, and route tables control who reaches whom. It costs per attachment-hour plus per GB processed. Use peering for 2–3 VPCs; a Transit Gateway beyond that or when an office network is involved.
How should an app on EC2 get permission to read S3? medium
Show answer
Attach an IAM role through an instance profile. The SDK then reads temporary credentials from the instance metadata service; they rotate automatically and expire, so a leak has a short life. Never put access keys in code, AMIs, or environment files. The role's permissions policy should be least privilege, for example s3:GetObject on arn:aws:s3:::my-bucket/* only, not s3:* on *. Policy evaluation: default deny, an explicit allow is needed, and an explicit deny anywhere wins. An instance profile holds exactly one role.
Follow-up: cross-account? The other account's role trusts yours; you call sts:AssumeRole.
What does S3 strong consistency guarantee, and what does it not? hard
Show answer
Since December 2020, any GET or LIST that starts after a successful PUT or DELETE response sees that write, in all Regions, at no extra cost. Updates to a single key are atomic: a reader gets the old or the new object, never a mix. What it does not give: no locking between concurrent writers (the latest timestamp wins, so you need your own lock or conditional writes), no atomic update across several keys, and bucket configuration (for example enabling versioning) is still eventually consistent; AWS suggests waiting 15 minutes after enabling versioning before writing. So S3 is not a transactional database.
Design secure user uploads of large videos to S3. hard
Show answer
The client asks your API for an upload; the API checks the user, then returns a pre-signed URL (or a set of URLs for multipart) for one exact key such as uploads/{userId}/{uuid}.mp4. The browser uploads straight to S3, so big bytes never touch your servers. Multipart lets parts upload in parallel and retry alone; one PUT tops out at 5 GB, multipart reaches 50 TB. Keep the URL short-lived (minutes); with role credentials it cannot outlive the role session anyway. An S3 event then triggers processing (Lambda or a queue → transcoder). Serve results through CloudFront with OAC, bucket stays private. Add a lifecycle rule to abort incomplete multipart uploads.
Host a static website on S3 with HTTPS and a custom domain. medium
Show answer
S3 website endpoints are HTTP only and need public objects, so do not use them directly. Instead: keep a private bucket with Block Public Access on; create a CloudFront distribution with the bucket's REST endpoint as origin and Origin Access Control, plus a bucket policy that allows only that distribution's ARN to s3:GetObject; attach an ACM certificate for your domain; point a Route 53 alias record at the distribution. OAC (not the legacy OAI) is required if the bucket uses SSE-KMS. CloudFront caches files at edges (24 hours by default), and origin fetches from S3 to CloudFront are free. AWS docs also suggest Amplify Hosting for this.
What breaks if one AZ goes down in your 3-tier app, and how do you prevent it? hard
Show answer
Walk each tier. CloudFront and Route 53 are global, so fine. ALB: it spans at least two AZs and stops sending to unhealthy targets; fine if the ASG has servers in another AZ, and the ASG relaunches capacity there. App servers: fine if spread across 2+ AZs with enough headroom (for example run 3 AZs at 67% max so two can carry the load). Database: RDS Multi-AZ fails over to the standby, typically in 60–120 s (page 13). Hidden failures: a single NAT gateway in the dead AZ cuts outbound traffic for all; EBS volumes and instance store in that AZ are unreachable; sticky sessions on dead servers lose state. Fix: NAT per AZ or regional NAT, stateless servers, sessions in a shared store.
Your AWS bill shows huge NAT gateway charges. How do you investigate and fix it? hard
Show answer
NAT charges are hourly plus per GB processed, so the cause is almost always data volume. Step 1: VPC Flow Logs on the NAT's network interface, grouped by destination, to see who talks to what. Common causes: (1) S3 or DynamoDB traffic going through NAT; fix with free gateway endpoints. (2) Calls to other AWS APIs (ECR image pulls, CloudWatch, SQS); fix with interface endpoints if their hourly cost is lower than the NAT data cost. (3) Cross-AZ hops: instances in AZ B using the NAT in AZ A also pay inter-AZ transfer; route each AZ to its own NAT. (4) Chatty third-party APIs; cache responses. Re-check after one week.
Design a multi-Region active-passive setup for a web app. hard
Show answer
Run the full stack in a primary Region and a smaller copy in a secondary. Route 53 failover records point to the primary ALB while its health check passes, and to the secondary when it fails. Data: replicate the database across Regions (for example an Aurora global database or cross-Region read replica, page 13) and S3 with Cross-Region Replication. The secondary's ASG runs at low size and scales up on failover. Trade-offs: replication is asynchronous, so you may lose the last seconds of writes (your RPO); DNS failover takes health-check time plus TTL (your RTO). Practise the failover regularly. For lower RTO, run active-active with latency routing, at higher cost and with harder write conflicts.

—Cheat sheet

Numbers to memorise, all checked 2026-10-25 on the linked pages memorise

FactValueSource
Regions (normal account, docs table)34; most have 3 AZsRegions
AZ distancemany km apart, within 100 kmS3 data protection
Spot warning2 minSpot notices
Savings Plans / RI max saving72%, 1 or 3 yearsSavings Plans
ASG grace period default300 s console, 0 CLI/SDKGrace period
Cross-zone defaultALB on; NLB, GWLB offHow ELB works
GWLB protocolGENEVE, port 6081GWLB
Lambda timeout900 sLambda quotas
Lambda memory128–10,240 MBLambda quotas
Lambda default concurrency1,000 per RegionConcurrency
Lambda sync payload6 MB request, 6 MB responseLambda quotas
Subnet sizes/28 to /16; 5 IPs reservedSubnet sizing
NAT gateway bandwidth5 Gbps → 100 GbpsNAT basics
Gateway endpointsS3 and DynamoDB, no chargeGateway endpoints
Route 53 multivalueup to 8 healthy recordsRouting policies
CloudFront default cache time24 hCloudFront
AssumeRole session15 min to 12 h, default 1 hAssumeRole
S3 durability99.999999999% (11 nines)Data protection
S3 object size5 GB per PUT, 50 TB multipartUploading
S3 request rate per prefix3,500 writes, 5,500 reads per sPerformance
Pre-signed URL max7 days (SigV4, IAM user)Pre-signed URLs
Glacier Deep Archive minimum180 daysStorage classes

—Sources

All pages read on 2026-10-25 sources