Designing a Social Media News Feed: A System Design Interview Walkthrough
4 views
"Design the news feed for a social network" is one of the most common system design questions because it touches nearly every core concept: read-heavy traffic, fan-out, caching, ranking and consistency trade-offs. Here is a structure you can follow in a 45-minute interview.
Start with requirements
Functional: users follow others, publish posts, and see a feed of recent posts from people they follow, newest or best first, with infinite scroll. Non-functional: feed loads in under a few hundred milliseconds, high availability, and eventual consistency is acceptable (a post showing up a few seconds late is fine). Ask about scale, for example 200 million daily active users, each opening the feed ten times a day and posting once or twice. That makes reads far more frequent than writes, which drives the whole design.
Sketch the core components
A post service stores posts (ID, author, content, timestamp, media references) in a database partitioned by post ID or author. A social graph service stores who follows whom. A feed service builds and serves each user's feed. Media goes to object storage behind a CDN, never inside the post database.
The key decision: fan-out on write versus fan-out on read
Fan-out on write (push): when someone posts, write the post ID into each follower's precomputed feed list, usually in an in-memory store. Reads become a fast lookup. The problem is celebrities: a user with 50 million followers turns one post into 50 million writes.
Fan-out on read (pull): store nothing per user and, when the feed is requested, fetch recent posts from everyone they follow and merge them. Writes are cheap but reads are slow and expensive.
The strong answer is a hybrid: push for normal users, pull for accounts above a follower threshold, and merge the two at read time. Saying this clearly, with the reason, is usually what interviewers are looking for.
Ranking
A pure reverse-chronological feed is the simplest. If ranking is in scope, describe a two-stage approach: gather a few hundred candidate posts, then score them with features such as recency, the viewer's past engagement with the author, and post popularity, then return the top results. You do not need machine learning details; showing where ranking fits in the pipeline is enough.
Pagination and caching
Use cursor-based pagination (the last seen post ID or timestamp) instead of page numbers, because new posts constantly shift offsets. Cache hot feeds and hot posts, and store only IDs in feed lists, hydrating post content from a post cache.
Edge cases worth mentioning
Deleted or edited posts (filter at read time), privacy changes and blocks, users who follow thousands of accounts, and cold start for brand-new users with no follows.
Communicating under pressure
Most candidates know these concepts; the difference is explaining them in a clear order while the interviewer interrupts with follow-ups. Practise the walkthrough out loud several times. Some candidates also use Linkjob AI (https://linkjob.ai), which gives real-time help during live job interviews and technical interviews, to stay structured when the conversation jumps around.