DEV Community

Cover image for Design Instagram: the photo-sharing system design interview walkthrough
Gowtham Potureddi
Gowtham Potureddi

Posted on

Design Instagram: the photo-sharing system design interview walkthrough

Design Instagram: the photo-sharing system design interview walkthrough

The request to design Instagram sounds like a news feed with pictures, and that framing is exactly where candidates lose the round. A text feed is a fanout problem; a photo-sharing feed is a fanout problem plus a media problem — billions of images and videos that have to be stored durably, processed into the right sizes, and delivered from the edge in milliseconds, all while the feed itself still loads in under a second. Doing it for a few thousand users is a database and a folder of files; doing it at Instagram scale, where storage is measured in petabytes and some accounts have 100M+ followers, is where the real Instagram system design decisions live.

The round turns on two axes that a plain news feed never fully tests. First, the media pipeline: how a photo gets uploaded without routing gigabytes through your application servers, how it is processed into thumbnails and resolutions, and how it is served fast to users anywhere in the world. Second, the feed: the same read-heavy fanout tradeoff — pay the cost at write time or at read time — with the same brutal celebrity edge case. This walkthrough follows the path a strong candidate draws in a system design interview — requirements, estimate, API and data model, high-level design, then the deep dives — and at each step it names the follow-up the interviewer uses to tell a memorised answer from an engineer who understands the tradeoff.

Title card for a system design interview walkthrough on designing Instagram, showing a photo uploading to a blob store and CDN beside a feed assembled from followed accounts, on a dark citrus-and-lavender background.

How the Instagram round is actually run

A photo-sharing design round runs about 60 minutes on a shared canvas — you draw the boxes and arrows while you talk, and the interviewer interrupts. It is a favourite because the one-line problem opens onto two deep topics at once: the moment you say "the user uploads a photo," the question becomes does that photo go through your servers, and how big is it, and the moment you say "I'll precompute each feed," you are back in fanout and the celebrity problem. Get the upload path and the fanout spine clean and you have shown the whole loop in one problem.

The interviewer rarely lets "the client sends the photo to the server" stand. "A user uploads a 4K video on a phone — walk me through exactly where those bytes go, and what your API servers touch." That question — whether you route media through your application tier or hand it straight to object storage — is the one a copied answer can never rehearse, and the one this round is really testing.

The rounds here are modelled on how the loop runs, not scraped from any candidate's recall. What matters for prep is the shape: a blank canvas, a clock, and a follow-up after every decision you make.

The five-step framework for any HLD round

Every high-level design answer fits the same spine. Say it out loud at the start so the interviewer knows you have a plan, then walk it:

  1. Clarify requirements — functional and non-functional, and what you are explicitly not building.
  2. Estimate — users, uploads, reads, and the storage footprint, to justify every later choice.
  3. High-level design — the boxes and arrows: client, upload path, blob store, CDN, feed service, fanout, stores.
  4. Deep dive — the two or three decisions that actually decide this system.
  5. Follow-ups — bottlenecks, failure modes, and what you would change at ten times the scale.

What the debrief measures

The score is not "right or wrong design." A good HLD debrief reads on four dimensions, and every move below maps to one: problem solving (did you keep media off the application path and then recognise the celebrity problem in the feed), communication (did you say why a pre-signed upload beats proxying bytes in a sentence), technical execution (blob store plus CDN, async media processing, hybrid fanout, cursor pagination), and time management (did you spend your 60 minutes on the media pipeline and fanout, not on the likes schema). Reading a walkthrough teaches the design; it does not teach you to deliver it on the clock while someone pushes back.

Step 1 — Requirements: what Instagram must do

Spend the first few minutes here. Jumping to boxes before you have scoped the problem is the fastest way to design the wrong system.

Type Requirement
Functional Upload a photo or video with a caption; follow accounts; generate a home feed of recent posts from the accounts a user follows; view a single post and a user's profile grid.
Functional (optional) Likes and comments, stories, direct messages, search and explore, hashtags — call these out, then scope most of them for later.
Non-functional Durable media storage (a photo must never be lost); low feed-read latency (feed loads in under a second) and fast media delivery everywhere; read-heavy (far more views than uploads); highly available; eventual consistency is acceptable — a new post can appear in a follower's feed a little late.

The sentence that earns points: "Media must be stored durably and served fast from the edge, and the feed is read far more than it is written, so the design is two problems — keep the heavy media off the application path and on a blob store behind a CDN, and move feed-assembly work off the read path by precomputing feeds, then handle the accounts where precomputing explodes." Say that and you have framed the entire design before drawing a box.

Step 2 — Capacity estimation (back of the envelope)

Estimation here proves two things: the storage footprint is the dominant cost, and the hard axis of the feed is the follower distribution, not raw volume.

Quantity Assumption Result
Daily active users ~500M —
Uploads ~100M photos/videos per day large but far smaller than reads
Average media size ~2 MB per photo (plus generated sizes), video larger ~hundreds of TB of new media per day → petabytes/year
Feed reads many refreshes/user/day read:write heavily skewed toward reads
Followers per account most have a few hundred a normal post fans out to hundreds
Followers per mega-account some have 10M–100M+ a single post fans out to tens of millions

The conclusion to say out loud: two numbers dominate. The total media storage grows without bound and is far too large and too heavy to sit in your database or pass through your API servers — it belongs in an object store fronted by a CDN. And the feed cost is not the average post; it is the shape of the follower graph, dominated by a handful of mega-accounts. You have now pointed the interview at both deep dives — media delivery and fanout — before anyone asked.

Step 3 — API and data model

The API is small. An upload path, a read path for the feed, and the follow graph:

Endpoint Operation
POST /media/upload-url Request a pre-signed upload URL — getUploadUrl(user_id, content_type) returns a URL the client uploads the bytes to directly.
POST /post Create the post record after upload — createPost(user_id, media_ref, caption) returns a post_id.
GET /feed Fetch a page of the home feed — getFeed(user_id, cursor, limit) returns ranked post ids + a next cursor.
POST /follow / DELETE /follow Follow or unfollow an account — mutates the follow graph.

The data model splits across stores. The post metadata is small and lives in a database; the media bytes live once in a blob store; the per-user feed is a list of post ids; the follow graph answers "who follows whom":

Entity Notes
post post_id (time-sortable), author_id, caption, media_ref (a key into the blob store, not the bytes), created_at. Small row in the post store.
media The actual image/video bytes and generated sizes, stored once in the blob store; addressed by media_ref and served through the CDN.
feed user_id → ordered list of post_id (the precomputed feed cache; ids, not full posts).
follow follower_id → followee_id, plus the reverse index followee_id → followers, for fanout.

The line to say: the database never stores the photo — it stores a reference; the bytes live in the blob store. Confusing the two is the classic mistake this round is watching for.

Step 4 — High-level design: upload path and feed path

Now the boxes. The design splits into a media path that keeps heavy bytes off your servers and a feed path that keeps reads fast:

  • Client → API gateway: the entry point for all requests.
  • Upload (write path): the client calls POST /media/upload-url, gets a pre-signed URL, and uploads the bytes directly to the blob store — the bytes never pass through your application servers. On completion it calls POST /post to create the small post record.
  • Media processing service: asynchronously generates thumbnails and multiple resolutions from the uploaded original, writes them back to the blob store, and marks the post ready.
  • Blob store + CDN: the object store (an S3-like service) holds every image and video durably; a CDN caches and serves them from edge locations close to the user.
  • Fanout service (write path): after the post record is created, asynchronously writes the new post_id into the feed cache of each follower — for normal accounts.
  • Feed service (read path): on GET /feed, reads the user's precomputed feed from the feed cache, hydrates post ids into post metadata, and returns a page by cursor; the client then loads each post's media straight from the CDN.
  • Graph / follow service: owns the follow relationships and answers "who follows this author?" for fanout.

Say explicitly that two things never touch your application tier at request time: the media bytes (client talks to the blob store and CDN directly) and the follow-graph join (the feed is already assembled in the cache before the user asks). Naming both unprompted is a signal the interviewer is listening for.

An Instagram architecture diagram showing the upload path where a client requests a pre-signed URL and uploads media directly to a blob store, a media processing service generating thumbnails and resolutions, and a CDN serving media, alongside the feed path where a post service persists a small post record, a fanout service writes post ids into follower feed caches, and a feed service reads the precomputed feed cache.

Deep dive: media storage and delivery

This is the decision that makes Instagram a photo-sharing system and not a text feed, and the one candidates most often get wrong by routing bytes through their own servers.

Upload: go direct, with a pre-signed URL. The client asks your API for permission to upload, and your API returns a pre-signed URL scoped to one object in the blob store. The client then uploads the bytes straight to the object store — your application servers never see the gigabytes. This keeps your API tier cheap and stateless, removes the upload bandwidth bottleneck, and is exactly how large media systems avoid melting their app servers on every 4K video.

Processing: do it asynchronously. A phone uploads one large original; the feed needs several sizes — a thumbnail for the grid, a medium size for the feed, the full size for the detail view. A media processing service picks up the uploaded original off a queue, generates those sizes, writes them back to the blob store, and marks the post ready. Doing this off the request keeps upload latency low and lets you re-process (new formats, new sizes) later.

Delivery: a CDN, always. Media is immutable once written, which makes it perfect for edge caching. Serve every image and video through a CDN so a user in another country fetches from a nearby edge node, not your origin. The database and your API return only the URL of the media; the heavy bytes travel client ↔ CDN. That split — metadata through your servers, bytes through the CDN — is the single most important sentence in this deep dive.

"A user uploads a 4K video — trace the bytes." The client requests a pre-signed URL and uploads directly to the blob store; the bytes never touch your API servers. A processing service then generates the needed resolutions asynchronously, and every view is served from the CDN, not your origin.

A diagram of Instagram media handling showing a client requesting a pre-signed URL then uploading bytes directly to a blob store, an async media processing service generating thumbnail and multiple resolutions, and a CDN caching and serving the media from edge nodes while the database holds only the media reference.

System Design
HLD · Photo-Sharing Feed · 60 min
Design Instagram out loud, with follow-ups

Practise on Zynter →

Deep dive: feed fanout and the celebrity problem

This is the decision that separates a senior answer from a textbook one, and it is the same spine every social feed shares. When do you assemble a feed — when the post is written, or when the feed is read?

Model How it works The catch
Fanout-on-write (push) When you publish, write the post id into every follower's precomputed feed cache immediately. Reads are instant (just read your cache), but writes are expensive — one post means one write per follower, which explodes for accounts with millions of followers.
Fanout-on-read (pull) At read time, fetch recent posts from everyone the user follows and merge them into a feed on the fly. Writes are cheap (store the post once), but reads are expensive — assembling a feed means a scatter-gather across everyone you follow on every refresh.

Pick push as the default and say why in one line: the feed is read far more than it is written and must load fast, so you pay the cost once at write time and keep the read path to a single cache lookup.

So where does push break? Exactly where an account has a huge number of followers. Fanning one post out to 100M follower caches on write is a write storm — it saturates the fanout workers, delays everyone else's posts, and writes to tens of millions of feeds that may never be read before the next refresh. That is the celebrity problem, and the fix is hybrid fanout: for the vast majority of accounts you push (their followers' feeds are precomputed, reads stay instant); for the handful of mega-accounts you don't fan out on write at all — their posts are pulled at read time. When a user requests their feed, the feed service reads their precomputed (pushed) feed and fetches the recent posts of the few celebrities they follow, then merges the two into the final ranked feed. You pay the write cost only where it is small and the read cost only where it is unavoidable, and the merge stays fast because a user follows only a handful of celebrities.

"A celebrity with a hundred million followers posts — walk me through what happens." You do not fan that out on write. The post is stored once; it is not written into 100M feeds. Every follower pulls that author's recent posts at read time and merges them into their pushed feed. Pushing it would be a write storm; the hybrid pulls it.

A diagram of hybrid fanout for Instagram showing normal accounts pushed into follower feed caches on write while a mega-account's post is stored once and pulled at read time, then merged with the precomputed feed when a follower requests their feed.

System Design
HLD · Celebrity problem · 60 min
Defend hybrid fanout out loud

Practise on Zynter →

Deep dive: the read path — feed cache, pagination, and the CDN

This is the decision that makes the under-a-second number real for a media-heavy feed. The read path has to touch almost nothing on disk, and the heavy bytes have to come from the edge.

The feed cache. Each user's feed is a list of post ids held in Redis — not the full posts, just the ids in ranked order. Fanout-on-write pushes ids into these lists; a read is a single cache lookup for one page. The small post metadata lives in the post store and is hydrated per page; storing ids, not copies of the post, keeps the fanout write cheap and the cache small.

The media comes from the CDN, not the feed path. This is the Instagram twist on the read path. The feed response is tiny — a page of post ids and metadata, each with a CDN URL for its media. The client then loads each image or video from the nearest CDN edge in parallel. Your feed service never streams image bytes; it returns references, and the CDN does the heavy lifting. That is how a feed full of photos still returns in milliseconds.

Pagination and ranking. The feed is paginated by cursor, not page number — the client sends the last post id or timestamp it saw and gets the next slice, which is stable under infinite scroll even as new posts arrive at the top. A ranking service applied at read orders the page by recency plus signals (engagement, affinity), over the bounded candidate set from the cache plus any pulled celebrity posts.

"The feed must load in under a second even though it is full of photos — where does that speed come from?" The feed response is just ids and CDN URLs read from a precomputed Redis cache in one lookup; the heavy media is fetched in parallel from CDN edge nodes, never streamed through your feed service. No graph join, no image bytes on the application path.

The follow-ups that decide the Instagram round

Scan the probes from each deep dive and they rhyme. Master these five and you are ready for a version of the question that is not drawn exactly like this one.

  • "Where do the uploaded bytes go?" → Straight to the blob store via a pre-signed URL; the API tier never proxies media. (problem solving)
  • "How do you serve a photo fast to a user on another continent?" → A CDN caches immutable media at edge nodes; the database returns only the URL. (technical execution)
  • "A celebrity with a hundred million followers posts — trace it." → Don't fan out on write; store the post once and let followers pull and merge it at read time. (problem solving)
  • "How does a photo-heavy feed still load under a second?" → A precomputed Redis feed cache read as one lookup returns ids and CDN URLs; media loads in parallel from the edge. (technical execution)
  • "How does infinite scroll stay stable as new posts arrive?" → Cursor pagination on the last-seen post id, not page numbers. (communication)

Each maps to a debrief dimension. Reading this list teaches you the answers; it does not teach you to deliver them while someone interrupts — that only comes from saying them out loud.

How to prepare: a one-week plan

You do not need fifty systems. You need this one cold and the framework automatic, so the next "design X" is just new nouns in the same five steps.

  • Days 1–2: Learn the five-step framework until it is reflex. Do Instagram end to end on paper — requirements, estimate, API, data model, the upload path and the feed path as two sets of boxes.
  • Days 3–4: Drill the media deep dive: pre-signed direct upload, async processing into sizes, CDN delivery, and the metadata-vs-bytes split. Say each tradeoff in one sentence.
  • Days 5–6: Own the fanout and read path — push vs pull, the celebrity problem and hybrid fanout, the feed cache returning ids and CDN URLs, cursor pagination. Answer each of the five follow-ups out loud.
  • Day 7: A full timed 60-minute round, narrating the whole way, with someone (or something) interrupting. This is the rep that counts.

This post is the deep walkthrough behind one row of the broader Top 25 system design interview questions — once Instagram is automatic, the same spine carries the rest of the list.

Frequently asked questions

How do I design Instagram step by step?

Follow the five-step HLD framework. Clarify requirements (upload a photo or video, follow accounts, generate a home feed, view a post and profile; durable media, low feed latency, read-heavy, eventual consistency is fine); estimate to show storage is the dominant cost and the follower distribution is the hard axis of the feed; define POST /media/upload-url, POST /post, and GET /feed with a small post record that references media; draw two paths — a media path (pre-signed direct upload → blob store → async processing → CDN) and a feed path (fanout service → feed cache → feed service); then deep-dive media storage and delivery, feed fanout with the celebrity problem and hybrid fanout, and the read path. Finish on the follow-ups about latency, storage, and scale.

How is designing Instagram different from designing a news feed?

The feed half is the same fanout problem — push versus pull, the celebrity problem, hybrid fanout, a precomputed feed cache. What Instagram adds is the media pipeline: billions of large images and videos that must be stored durably in a blob store, processed into multiple sizes asynchronously, and served from a CDN. The key extra decision is keeping those bytes off your application servers — clients upload directly to object storage via a pre-signed URL and read media directly from the CDN, so your API only ever handles small metadata.

How is media stored and served in Instagram's design?

Media bytes live once in a blob store (an S3-like object store) for durability, never in the database — the database stores only a reference. On upload, the client gets a pre-signed URL and sends the bytes straight to the blob store; a processing service then generates thumbnails and resolutions asynchronously. Because media is immutable once written, it is served through a CDN that caches it at edge locations, so a user anywhere fetches from a nearby node. The feed returns CDN URLs, and the client loads the images and videos in parallel from the edge.

What is the celebrity problem, and how does hybrid fanout solve it?

The celebrity problem is the failure case of pure fanout-on-write: when an account has tens or hundreds of millions of followers, pushing one post into every follower's feed cache means tens of millions of writes, which saturates the fanout workers and delays everyone else's posts. Hybrid fanout decides push or pull per account — push for the vast majority of normal accounts so their feeds stay precomputed, and pull for the handful of mega-accounts, whose posts are stored once and fetched at read time. A follower's feed is then the pushed feed merged with the recent posts of the few celebrities they follow.

How does Instagram's feed load in under a second if it is full of photos?

Because the feed response carries no image bytes. The feed is a ranked list of post ids in a Redis cache, read in a single lookup for one page; hydration adds small metadata and a CDN URL per post. The heavy images and videos are then loaded in parallel directly from CDN edge nodes close to the user, never streamed through your feed service. No graph join happens at request time, and no media touches the application path, which is what keeps a photo-heavy feed fast.

How do I practise a system design interview out loud?

Reading a walkthrough is not the same as defending a design while someone interrupts. On Zynter, the HLD track runs live voice rounds modelled on how real system design loops run — you talk through a shared design on the canvas, and a voice interviewer pushes with the follow-ups above one at a time, then gives you a debrief on problem solving, communication, technical execution, and time management. The score is a practice signal, not a hiring decision.

Practise it on Zynter

You can read every tradeoff. The round is won on the media path and the celebrity problem.

Pick the photo-sharing feed round, draw the upload and feed paths on the canvas, and defend them out loud to a voice interviewer that keeps asking "where do the bytes go?" and "what about the account with a hundred million followers?" — then read the debrief. Zynter.ai is on-demand mock interviews modelled on real company loops, with 150+ rounds across 20 companies including the HLD system design track (Sep 2026).

Practise the photo-sharing feed round →
Browse all interview tracks

Top comments (0)