Photo and video sharing platform inspired by Instagram's published engineering: stateless app servers, media in object storage behind a CDN, sharded Postgres with shard-encoded ids, precomputed feeds and async processing. A teaching design, not Meta's current internal architecture.
See why one server with photos on its disk and one database can't grow.
What was missing: Nothing yet: one server and one database.
Why that's risky: Photos tie users to one machine's disk, every image is served by the app server, and every page view is a database query.
What gets added: An app server that stores uploaded photos on its own disk and keeps users, follows and posts in one Postgres database.
Trade-offs: Fast to build, as Instagram's first version was, but nothing can be scaled independently.
Make app servers interchangeable and serve photos from the edge.
What was missing: Photos lived on one server's disk and every read went to Postgres.
Why that's risky: One Postgres primary still holds every post and follow, and it will run out of write capacity and disk.
What gets added: Stateless app servers behind a load balancer, photos in object storage served through a CDN, and Memcached in front of Postgres for hot posts, profiles and counts.
Trade-offs: Cached counts (likes, followers) can be slightly stale; that's acceptable for display.
Split the data across many databases without losing the ability to sort and locate posts.
What was missing: One Postgres primary held all users and posts.
Why that's risky: Building a feed still means querying the recent posts of every account a user follows, across many shards.
What gets added: Posts and users split across sharded Postgres: thousands of logical shards mapped onto fewer machines, so shards can move between machines as data grows. Each post id packs creation time, shard id and a sequence number into 64 bits.
Trade-offs: Queries across shards (like 'everyone's recent posts') become expensive; data must be laid out so common reads hit one shard.
Build each user's feed when posts are published, not when the feed is opened.
What was missing: Feeds were assembled from many shards on every open.
Why that's risky: Uploads still resize photos and transcode video inline, and notifications are sent synchronously.
What gets added: A task queue and fan-out workers that write each new post id into every follower's feed in a Cassandra-style feed store partitioned by user. Opening the feed reads one partition and hydrates posts from Memcached.
Trade-offs: Each post costs a few hundred writes; reads, which are far more frequent, become a single partition read.
Return uploads instantly and do the heavy work in the background.
What was missing: Resizing, transcoding and notifications ran inside the upload request.
Why that's risky: There is no way to find accounts or hashtags, and nothing protects against scraping.
What gets added: Media jobs and workers that resize photos into each size the apps need and transcode video; notification jobs and workers that send pushes for likes, comments and follows.
Trade-offs: A post appears a moment after upload while its sizes are generated.
Let people find accounts and hashtags, block abuse, and watch the system.
What was missing: No search, no abuse protection, and no visibility into per-shard load.
Why that's risky: Remaining risk is regional and hot-shard: a celebrity's shard can get far more traffic than others.
What gets added: A search service and index over usernames, hashtags and captions fed by an indexing task, a rate limiter in front of the app servers, and monitoring of latency, queue backlogs, cache hit rate and per-shard load.
Trade-offs: Search results lag new posts by seconds.
Instagram uses fanout-on-write where new posts are pushed to followers' feed caches asynchronously.
Blob storage is optimized for large binary objects like images and videos while databases store structured metadata.
Search queries are served using Elasticsearch clusters with inverted indexes.
Images and videos are cached in CDN edge nodes so users fetch them from nearby locations.
You're in the middle of an interview session. Leaving now will end your current attempt.
Explore concept overviews, real-system examples, key tradeoffs, and interview talking points for each roadmap section.
You've conquered this phase. These are the skills you now own: