SD-4 · PHOTO SOCIAL NETWORK · INTERACTIVEBreak it.
Break it.
Then fix it.
Turn up the scrolling, watch what melts, and add the parts a real photo app needs. Every switch is a decision you would defend in an interview.
CHALLENGEServe 200K feed loads/s with feed p99 under 150 ms, images under 400 ms, posts under 500 ms and no errors.
StatusDOWNAt 50K feed loads per second
Feed p99500+ msTarget under 150 ms
Image p995,000+ msTarget under 400 ms
Post p995,000+ msTarget under 500 ms
Errors90%Requests being dropped
Monthly cost$12,070Images from object storage
PhonesLIVE
50K feed loads/s · 833 posts/s500K images/s
Load balancerOK
Autoscales app serversspreading 52K/s
Object storageDOWN
2 MB originals500K / 400K GETs/s
App servers × 37OK
Stateless52K / 74K calls/s
Post DBDOWN
20 index reads per feed load1.0M reads/s
Every feed load is a big query. Building a feed from 150 followed accounts costs about 20 index reads, 1.0M a second. Push post IDs into a cache when someone posts, so a feed load is one memory read.
13×Smaller feed image150 KB instead of a 2 MB original, made once by image workers.
95%CDN hit rateA photo never changes, so the edge keeps it for 30 days.
300Followers per postOn average, so a post becomes about 300 feed inserts.
1M+Followers: pull, not pushHuge accounts are merged in at read time instead of fanned out.
Want the reasoning behind every switch?Visual walkthroughFull write-up
Was this lab useful?Your vote tells us what to improve next.