“Design Instagram” is a news feed question with a storage question attached. The interviewer wants two things: a feed that loads fast for 500 million people when a handful of accounts have more followers than most countries have citizens, and a photo pipeline that never loses an upload and never makes a phone download a 2 MB original to show a thumbnail. Get those two right and the rest is boxes.
This walkthrough follows the 45-minute clock: requirements, the numbers that matter, the high-level design with one upload and one feed read walked through it, two deep dives, then trade-offs. The real-world references are Twitter’s timeline architecture, which is still the clearest public account of fan-out at scale (High Scalability, 2013, from Raffi Krikorian’s QCon talk), and Facebook’s paper on running memcache at scale (NSDI 2013).
Requirements and scope (0 to 5 minutes)
Ask, write the answers on the board, and cut. The questions that matter:
- Upload. A photo with a caption. One photo per post is enough; say you would extend it to several.
- Follow. One-way: I follow you, you need not follow me. This is what makes the feed hard, because popular accounts get millions of followers.
- Home feed. The posts from the people I follow, newest first. Ask whether it is chronological or ranked; assume chronological and say ranking is a layer you can add.
- Likes. A count on each post and whether I liked it.
- Out of scope unless asked. Stories, direct messages, explore and search, comments, video. Name them so the interviewer knows you did not forget.
Non-functional requirements (how well the system works rather than what it does): the feed should load in a few hundred milliseconds as a rule of thumb; the system should favour availability over consistency, since a post that shows up in a follower’s feed a few seconds late is fine; and an uploaded photo must never be lost, which is the one place to be strict.
What to say: “I will assume photo posts with captions, one-way follows, a chronological home feed and likes, with stories, messages and search out of scope. The feed is read-heavy and the uploads must be durable, so I will spend my deep dives on the feed and on media. Tell me if you want ranking in scope.”
The numbers that matter (5 to 8 minutes)
Instagram passed 3 billion monthly active users in 2025 (coverage of Meta’s announcement). For the interview, assume a smaller number and say so: 500 million daily active users is a round figure that makes the math readable without changing any decision. Everything below is a rule-of-thumb estimate from that assumption.
- Uploads. If one in ten daily users posts once a day, that is 50 million photos a day. A day is 86,400 seconds, call it 100,000: about 500 uploads a second on average, 1,500 at peak using the usual two-to-three-times rule.
- Feed reads. If each user opens the feed ten times a day, that is 5 billion feed loads a day: 50,000 a second on average, 150,000 at peak.
- The ratio. 100 reads for every write. This one number decides the feed design: do the work when a post is written, so reads are cheap.
- Storage. Assume a 2 MB original plus three generated sizes (thumbnail, feed size, full screen) adding about 0.5 MB. 2.5 MB x 50 million = 125 TB a day, or about 45 PB a year. The metadata rows are tiny next to that.
What to say: “About 1,500 uploads a second at peak, 150,000 feed reads a second, and 125 terabytes of new photos a day. The hundred-to-one read ratio tells me to build the feed at write time. The storage number tells me photos go to object storage behind a CDN, and that the cost of keeping them is a real trade-off I will come back to at the end.”
For reference, Twitter’s reported shape was the same: about 300,000 timeline reads a second against roughly 5,000 tweets a second on average, 7,000 at the daily peak and over 12,000 during big events (High Scalability). Saying that your estimate matches a public system’s shape is worth a sentence. The estimation guide covers the constants used here.
High-level design, then walk one upload and one feed read (8 to 20 minutes)
The parts, in the order you draw them:
- Upload service. Hands the app a signed URL (a temporary link that allows one upload) so the photo bytes go straight to object storage instead of through your servers. Then it records the post.
- Object storage. Originals and generated sizes. Durable by design: it is the component you trust not to lose the photo (AWS S3).
- Image workers behind a queue (a buffer that holds jobs until a worker is free). They make the three sizes. Resizing is slow and must not block the upload response.
- Post metadata database. One row per post: post id, user id, caption, media key, created time. A relational database sharded (split across servers) by user id, so one user’s posts live together (MongoDB on sharding, same idea in any store).
- Social graph service. Who follows whom, stored both ways: my followers, and who I follow. Fan-out needs the first; a profile page needs the second.
- Feed service and feed cache. A list of post ids per user in Redis (an in-memory store), pre-built, which the feed service reads and turns into posts.
- Like service. A counter per post and a set of who liked it.
- CDN (content delivery network, caches near users). Every image the app shows comes from here (AWS on CDNs).
One design detail worth saying out loud: give posts time-sortable ids. Twitter’s Snowflake packs a 41-bit timestamp, a 10-bit machine id and a 12-bit sequence into one 64-bit number (Twitter Snowflake), so sorting by id is sorting by time and the feed list needs no second field.
Walk the upload first.
What to say: “The app asks the upload service for a signed URL and gets a media id. It puts the 2 MB file straight into object storage. Then it posts the caption and media id with an idempotency key, a unique id for this post so a retry on a bad connection does not create it twice. The upload service inserts the post row, drops a resize job and a fan-out job on the queue, and returns 201 Created in a few milliseconds. An image worker makes the three sizes and writes them next to the original. A fan-out worker asks the social graph for the author’s followers and pushes the post id onto each follower’s feed list. From the user’s side the post is live at once; from the followers’ side it appears within seconds.”
Now the feed read.
What to say: “The app calls GET /feed with a cursor, which is the id of the last post it saw. The feed service reads the next 20 post ids from the user’s list in Redis. It fetches those 20 rows from the metadata cache in one call; the two that miss come from the post database and are written back to the cache, the cache-aside pattern (AWS ElastiCache). It returns the 20 posts with CDN URLs for the feed-size images, and the app loads the images from the CDN. No feed read touches the social graph or scans the post table, because the list was built at write time.”
Then stop: “That is the basic design. The two places it breaks are the fan-out for accounts with millions of followers and the media path under a viral post. Which first?” Midpoint, whole picture on the board.
Deep dive one: the feed and the celebrity problem (20 to 29 minutes)
Two ways to build a feed, and the interviewer wants both named with their costs:
- Fan-out on write (push). When a post is created, push its id into every follower’s pre-built list. Reads are one Redis call. Writes cost one insert per follower. Twitter’s figures: a post from an account with 20,000 followers meant “as many as 20K inserts”, delivering to one million followers took about 3.5 seconds at the median and up to 5 minutes at the 99th percentile for the largest accounts (High Scalability).
- Fan-out on read (pull). Store nothing per follower. When a user opens the feed, fetch the recent posts of everyone they follow and merge them. Writes are one row. Reads are hundreds of lookups, which at 150,000 feed reads a second is the wrong side of the hundred-to-one ratio.
The problem with pure push is the account with 50 million followers. One post becomes 50 million inserts, the fan-out queue backs up, and everyone’s feed goes stale behind it. Twitter’s answer was to stop fanning out for very popular accounts and merge their posts in at read time instead: “For people like Taylor Swift don’t bother with fanout anymore” (High Scalability).
The hybrid, which is the answer to give:
- Normal users: push. Fan out on write to every active follower’s list. Twitter kept lists only for users active in the last 30 days and rebuilt the rest on login, which cuts the write cost and the memory for a service where most accounts are quiet (High Scalability).
- Popular accounts: pull. Above a follower threshold (10,000 is a reasonable dial; say it is a dial), skip the fan-out. The post is written to the author’s own post list only.
- On read: merge. The feed service reads the user’s pre-built list, fetches the recent posts of the few popular accounts the user follows (most people follow a handful), merges by post id, and returns the top 20. Because ids are time-sortable, the merge is a simple sort.
Memory for the lists: Twitter capped each home timeline at 800 entries and kept them in a Redis cluster with “a couple of terabytes of RAM”, with each entry holding the tweet id, the author id and a few bytes of flags (High Scalability). For 500 million users, an 800-entry list of 16-byte entries is about 13 KB per user, roughly 6 TB for everyone, less if only active users keep one. That is a cluster, not a problem.
What to say: “Hybrid fan-out. Push for everyone under the threshold, so a feed read is one Redis call. Pull for accounts over it, merged in at read time, so one celebrity post never costs 50 million writes. The cost is that a feed read for someone who follows many celebrities does a few extra lookups, and that the threshold is a dial we tune in production. I cap each list at a few hundred entries and only keep lists for active users.”
The follow-up to expect: “A user with 10 million followers posts. What breaks?” A fan-out follow-up of this kind is where a senior candidate’s round at Rippling went wrong (Blind, September 2025). Do not redraw. Point at the fan-out worker, say it is skipped for that author, and point at the merge step.
Deep dive two: media storage and delivery (29 to 38 minutes)
Sizes. Store the original, untouched, and generate the sizes the app actually shows: a thumbnail for grids, a feed size, a full-screen size. The app never downloads the original. Name the sizes by a content hash or the media id plus a suffix, and make them immutable: a photo never changes after upload, so a CDN can cache it for a year and a client can cache it forever.
CDN. Every image URL points at the CDN, which pulls from object storage on the first request in each region and serves from cache after that. This is a pull CDN, the right shape for user uploads, since nobody knows which of today’s 50 million photos will be popular. Private accounts need signed, expiring URLs so a leaked link stops working.
Metadata cache. The post rows, user profiles and like counts sit in a memcache or Redis layer in front of the database, cache-aside: read the cache, on a miss read the database and fill the cache, and on a write delete the cache entry so the next read refills it (AWS ElastiCache).
The viral post and the thundering herd. Here is where this deep dive earns its place. A post goes viral. Its like count changes hundreds of times a second, and every change deletes the cached row. Thousands of feed reads a second now miss the cache at the same moment and all go to the database for the same row. Facebook’s memcache paper calls this a thundering herd and describes the fix, leases (NSDI 2013, Scaling Memcache at Facebook):
- On a cache miss, memcache hands the first client a lease, a 64-bit token tied to that key, and tells the others to wait a moment instead of going to the database.
- The lease holder reads the database and sets the value with its token. The server only accepts the set if the token is still valid, which also prevents a slow client writing a stale value over a fresh one.
- Tokens are handed out at most once every 10 seconds per key by default. In their measurement, the peak database query rate for a set of herd-prone keys dropped from 17,000 a second without leases to 1,300 a second with them.
Second fix, for the like count itself: do not invalidate the post row on every like. Keep the count in a Redis counter that increments in place, and show it from there, or fold a batch of likes into the row every few seconds. Nobody needs a like count that is exact to the millisecond.
What to say: “Media is immutable, stored in three generated sizes plus the original, served through a pull CDN with long cache lifetimes. Metadata is cache-aside with leases, so a viral post causes one database read per cache miss window instead of thousands. The like count lives in its own counter so it does not churn the cached row.”
The reflex to resist here is reaching for a cache before naming the problem it solves. An interviewer on Hacker News describes candidates whose only answer to any bottleneck is “add a cache” (Hacker News, March 2025). Here you named the herd first and the lease second, which is the order that earns credit.
Trade-offs and what you cut (38 to 43 minutes)
Choice, cost, what was cut, what comes next.
- Feed freshness versus write cost. Push makes the feed instant to read and costs one insert per follower per post, with a delay of seconds to minutes for big accounts. Pull is free on write and expensive on every read. The hybrid buys the best of both at the cost of a threshold to tune and a merge step. For a read ratio of a hundred to one, the hybrid is the right trade.
- Chronological versus ranked. A chronological feed is a sorted list of ids, cheap to build and cheap to read. A ranked feed needs a candidate set, features for each candidate and a scoring step at read time, which is more CPU per feed load and a separate system to build and keep fresh. Start chronological; design the feed service so a ranking stage can sit between the list and the response.
- Storage cost. 45 PB a year of photos at S3 Standard’s $0.023 per GB-month in US East (AWS) is 45 million GB x $0.023, about $1 million a month to keep one year’s uploads, and it grows every year. Cloudflare R2 lists $0.015 per GB-month with no egress fees (Cloudflare) and Backblaze B2 about $0.007 (Backblaze). The moves: keep generated sizes hot and move originals older than a year to a cold tier; and do not store a 2 MB original when the app will never show it at that size.
What to say: “I chose hybrid fan-out into pre-built Redis lists, immutable media in object storage behind a pull CDN, and cache-aside metadata with leases, because the feed is a hundred times more read than written and the photos are the expensive part to keep. The costs are a fan-out delay of seconds for big accounts, a threshold to tune, and about a million dollars a month per year of photos at list prices. What I cut: stories, messages, search and ranking. With more time I would add the ranking stage and move old originals to a cold tier.”
For the feedback phrases interviewers write when this summary is missing, and how to fix each, see why candidates fail system design interviews.
What the interviewer probes at each level
- Mid-level. Can you draw the upload path with object storage and a CDN, and the feed path with a pre-built list? Do you know why uploads go straight to object storage and not through your servers? Can you explain push versus pull in one sentence each? A complete picture with the queue in the right place passes.
- Senior. The hybrid fan-out, with the threshold and the merge. The numbers: read ratio, list memory, storage per day. The thundering herd and leases, not just “add a cache”. Idempotent uploads. Time-sortable ids. Every component with its failure mode, because naming a technique without its trade-offs is what failed the Rippling candidate (Blind, September 2025).
- Staff. The economics of storage over years and what you would tier. Ranking as a product decision with an infrastructure cost. How to migrate from chronological to ranked without a feed outage. Multi-region: where the feed lists live for a user who travels. And a decision on each; Hello Interview’s staff guide names listing options without choosing as the most common failure (Hello Interview).
The same fan-out logic appears in the 20 system design interview questions under the news feed and chat entries, and design Netflix shows the opposite delivery choice, a push CDN filled overnight, for a catalogue known in advance. The cheat sheet has the one-line versions of cache-aside, sharding and the CDN for the night before.
How InterviewStorm helps
InterviewStorm is a practice partner for this round. Give it “design Instagram” in a mock call and it lays out the shape of a strong answer: the requirements to confirm, the numbers that pick the feed design, an architecture diagram it draws itself, the upload and the feed read traced box by box, the schema and the APIs, the scaling moves such as the hybrid fan-out, and the trade-offs to name, so you can rehearse the whole clock out loud and compare your board with a complete one. See the system design feature.
Most companies do not allow AI help during the design round itself, and interviewers say they watch for it. Use it live only where the employer allows it, and to practise everywhere else. Follow each employer’s interview rules. Do not use InterviewStorm in proctored tests, exams, or anywhere AI help is not allowed.
The free trial is 20 minutes in total, up to 15 minutes per session, with no credit card. Try it free.
For the rest of the loop, read the guides on coding interviews and the STAR method.
Share Articles:
Similar Posts