Amazon S3
medium 30 minAmazon S3 stores objects, whole files with a key and metadata, in buckets that you reach over HTTP.
See it run
A write over three zones, direct uploads, parts, versions, prefixes and a lifecycle.
Operations
PUT, GET and a lost zone
One object is written, read, and read again while a zone is down.
Step 1 of 5
Check
The front end checks the signature and every policy. A deny anywhere ends it.
Step 1: Check
def put(key, data): check(signature, policies) store_redundantly(data, zones=3) namespace[key] = places # now visible return 200def get(key): return rebuild(namespace[key])- Extra cost
- 3 zones
- Protects
- Lost zone
Durability is about not losing data. Availability is about answering now. Name both.
In the real world
The same amazon s3 doing real jobs. Pick one and step through it.
Two clients change the same small object.
Step 1 of 3
Both read
Same start
A and B read the settings with ETag e1.
Step 1: Both read
Common mistakes
The bugs interviewers watch for, with the fix beside each.
A public bucket
criticalAnyone with the address can read it, and search tools find such buckets.
WrongBlock Public Access: offPrincipal: "*"RightBlock Public Access: ononly the CDN may readThe client chooses the key
criticalA user can overwrite another user's object.
Wrongpresign("PUT", request.body.key)Rightkey = f"uploads/{user.id}/{new_id()}"presign("PUT", key, minutes=15)Read, change, write without a condition
majorThe latest timestamp wins and the other change disappears.
Wrongput("settings", new)Rightput("settings", new, if_match=etag)Millions of tiny objects
majorYou pay per request, listings are slow, and cold classes bill at least 128 KB or add metadata.
Wrongone object per eventRightbatch to files of many megabytesthen compressForgotten parts and versions
minorThey are invisible in a normal listing and stay on the bill.
Wrongno lifecycle ruleRightabort uploads after 7 daysexpire old versions after 30 days
Interview tips
How to explain it
- A key and an object over HTTP.
- Three zones or more, eleven nines by design.
- Strongly consistent for each key.
Numbers to know
- 3,500 writes or 11,000 reads per prefix.
- 50 TB object, 5 GB single PUT.
- About 100 to 200 ms for small objects.
Reach for it when
- There are files in the design.
- Data is written once and read many times.
- It must be kept for years.
Before launch
- Private bucket, CDN in front.
- Versioning and lifecycle rules.
- A tested restore.