TGViewer
Coding Interview Preparation Coding Interview Preparation @coding_interview_preparation Β· 5.9K subscribers
Post #1415 348
πŸ—οΈ SYSTEM DESIGN MONDAY #6 - Let's Design Instagram (Feed + Media at Scale)

Bigger system this week. Core requirements:

βœ… Users post photos/videos
βœ… Users follow other users
βœ… Users see a feed of posts from people they follow
βœ… Massive read traffic - feeds are viewed constantly, posts created far less often

The hardest question in this whole design: how do you GENERATE the feed?

πŸ”Ή Option A - Pull model (fan-out on read): When a user opens their feed, query posts from everyone they follow, merge, and sort by time.

[User requests feed] β†’ [Query posts from all 500 people they follow] β†’ [Merge + sort] β†’ [Return]

Simple, but SLOW for users following many accounts - that query fans out wide every single time they open the app.

πŸ”Ή Option B - Push model (fan-out on write): When someone posts, immediately push that post into the precomputed feed of every follower.

[User posts] β†’ [Push post into feed_cache for each of their 10K followers]

Feed reads become instant (just read your precomputed feed) - but this completely breaks down for celebrities with 50 million followers, since one post would mean 50 million writes.

βœ… The real answer (hybrid): Push model for regular users, pull model for accounts above a follower threshold (celebrities). Merge the two at read time. This exact hybrid approach is used by real large-scale social platforms, and mentioning it shows you understand that there's rarely one clean solution at true scale - just the least-bad tradeoff for each case.

Media storage: Photos/videos themselves don't belong in your database - they go in object storage (like S3), with only the URL/reference stored in the database. A CDN (Content Delivery Network) then caches that media geographically close to users, so someone in Tokyo isn't fetching an image from a US-based server every time.


[App Server] β†’ stores reference β†’ [Database]
[App Server] β†’ stores actual file β†’ [Object Storage] β†’ cached globally by β†’ [CDN]


Which feed generation approach would you have guessed first, before reading the hybrid answer? πŸ‘‡
More from @coding_interview_preparation
  1. Oct 8, 2026If you're prepping for system design interviews, this repo is gold It contains a curated,…
  2. Oct 6, 2026document post
  3. Oct 4, 2026πŸ’Ό Why Your Resume Gets Rejected Before a Human Reads It You may have good skills and proj…
  4. Oct 2, 2026🧠 Coding Myths You Should Stop Believing There's a lot of advice online about learning to…
  5. Oct 1, 2026Most Asked Topics in AI Engineer Interviews Based on 2026 candidate reports
  6. Sep 30, 2026πŸ’Ό What Companies Actually Look For in a Fresher Think companies only care about your CGPA…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook β†’Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 β†’