Uploaded November 2026 | Updated November 2026, 20 hours ago
Five new posts arrive, and you scroll into five you've already seen. In a System Design Interview you get exactly this question: "Design the Instagram feed."
System Design Interview, Day 008. Most candidates say "fetch the posts of everyone the user follows from the database, and sort by time". One line like that, and the round is over. Crores of users, each following hundreds of accounts, and that query on every feed open: the database goes down.
- Fix 1: a ready-made feed for every user. A feed cache, say in Redis, holds a list of post IDs per user, newest first, capped (say at 500 IDs) so older ones drop off. Opening the feed is just reading that list
- Fix 2: how the list gets filled. A new post is saved to storage and the database, then an event goes onto a queue. Fan-out workers look up the author's followers and add the post ID to every follower's list. It's async, so the person posting never waits
- Fix 3: celebrities. For an account with crores of followers, don't fan out. Their posts are pulled and merged into your list when you open the feed. That's the hybrid
- Fix 4: ranking and hydration. Take the top few hundred candidates from the list and order them with a ranking model: who you interact with, how new the post is, how many likes it's getting. Then hydrate: from the IDs, fetch the real post, the photo's CDN link and the like count. And filter out deleted posts and posts from blocked accounts
- The question after that: "New posts arrive at the top while the user scrolls. What happens on the next page?" With offset paging ("the next twenty after the first twenty"), five new posts shift everything and the user sees five posts again. The fix: a cursor. Return the post shown last with every page and start the next page right after it. For a ranked feed, save the session's ranked list for a while and let the cursor move through it
Say this in the round and you stand out: a ready feed cache for every user, async fan-out, pull for celebrities, ranking and hydration, and pagination with a cursor.
Next System Design Interview episode: design Uber's ride matching. Comment and tell me: which feed do you prefer, by time or ranked?
kgptalkie.com
#shorts #SystemDesign #SystemDesignInterview #InstagramFeed #FanOut #NewsFeed #BackendInterview #InterviewPrep #SoftwareEngineering #DistributedSystems #Pagination #KGPTalkie
Five new posts arrive, and you scroll into five you've already seen. In a System Design Interview you get exactly this question: "Design the Instagram feed."
System Design Interview, Day 008. Most candidates say "fetch the posts of everyone the user follows from the database, and sort by time". One line like that, and the round is over. Crores of users, each following hundreds of accounts, and that query on every feed open: the database goes down.
- Fix 1: a ready-made feed for every user. A feed cache, say in Redis, holds a list of post IDs per user, newest first, capped (say at 500 IDs) so older ones drop off. Opening the feed is just reading that list
- Fix 2: how the list gets filled. A new post is saved to storage and the database, then an event goes onto a queue. Fan-out workers look up the author's followers and add the post ID to every follower's list. It's async, so the person posting never waits
- Fix 3: celebrities. For an account with crores of followers, don't fan out. Their posts are pulled and merged into your list when you open the feed. That's the hybrid
- Fix 4: ranking and hydration. Take the top few hundred candidates from the list and order them with a ranking model: who you interact with, how new the post is, how many likes it's getting. Then hydrate: from the IDs, fetch the real post, the photo's CDN link and the like count. And filter out deleted posts and posts from blocked accounts
- The question after that: "New posts arrive at the top while the user scrolls. What happens on the next page?" With offset paging ("the next twenty after the first twenty"), five new posts shift everything and the user sees five posts again. The fix: a cursor. Return the post shown last with every page and start the next page right after it. For a ranked feed, save the session's ranked list for a while and let the cursor move through it
Say this in the round and you stand out: a ready feed cache for every user, async fan-out, pull for celebrities, ranking and hydration, and pagination with a cursor.
Next System Design Interview episode: design Uber's ride matching. Comment and tell me: which feed do you prefer, by time or ranked?
kgptalkie.com
#shorts #SystemDesign #SystemDesignInterview #InstagramFeed #FanOut #NewsFeed #BackendInterview #InterviewPrep #SoftwareEngineering #DistributedSystems #Pagination #KGPTalkie










