Design a News Feed: System Design Interview Walkthrough
How to answer the news feed (Facebook, Instagram, Twitter timeline) question: fan-out on write vs read, the celebrity problem, feed ranking, storage, caching and the trade-offs interviewers want named.
The news feed question is about one idea: where do you do the work, at write time or read time? See the cheat sheet for the general framework.
1. Requirements
Functional: create posts, follow users, view a feed of followed users' posts, pagination, optionally ranking and media. Non-functional: fast feed loads, high availability, eventual consistency is acceptable, large read:write ratio.
2. Core components
- Post service + post store (posts by ID)
- Social graph service (who follows whom)
- Feed service (builds and serves feeds)
- Feed cache (per-user list of post IDs)
- Media storage and CDN
3. Fan-out on write (push)
On a new post, a worker looks up the author's followers and prepends the post ID to each follower's feed list in the cache.
- Pros: reads are a single cache lookup
- Cons: heavy for users with huge followings; wasted work for inactive followers
4. Fan-out on read (pull)
At read time, fetch the people you follow, pull their recent posts and merge.
- Pros: cheap writes, no wasted precomputation
- Cons: slow reads, heavy graph and post queries on every load
5. Hybrid (the usual answer)
- Normal users: fan-out on write
- High-follower accounts: skip fan-out; their posts are merged into the feed at read time
- Skip precomputing for inactive users and rebuild on login
6. Reading the feed
- Load the precomputed list of post IDs from cache
- Merge recent posts from followed celebrity accounts
- Hydrate IDs into post objects (batch lookups, cached)
- Rank, then return one page with a cursor
7. Ranking
Begin with reverse-chronological. Mention that a production system scores candidates using recency, affinity with the author, post type and engagement signals, usually in a separate ranking service.
8. Edge cases and follow-ups
- Deleting a post or unfollowing: remove from feed caches lazily or filter at read time
- Cache size: keep only the latest N IDs per user
- Hot posts: cache hydrated objects; use a CDN for media
- Consistency: it's fine if a new post appears seconds late
Estimating the numbers
Assume 500 million users, 100 million daily actives, each following 200 accounts on average and posting once a day.
- New posts per day: about 100 million.
- Fan-out on write: 100 million posts x 200 followers = 20 billion feed-list inserts per day, roughly 230,000 per second. Large but feasible with sharded Redis.
- Feed reads: if each active user opens the feed 10 times a day, that is a billion reads, roughly 12,000 per second on average, with peaks several times higher.
The write amplification explains why celebrity accounts need special handling.
The feed cache
Each user's feed is a capped list of post IDs, for example the latest 500, stored in Redis. Reading a page means taking a slice, then hydrating post objects in a batch from a post cache. This keeps the read path to two or three fast lookups.
Ranking in layers
- Candidate generation: gather recent posts from the precomputed feed plus pulled celebrity posts.
- Scoring: a model estimates relevance using recency, author affinity, content type and engagement.
- Filtering and diversity: remove duplicates, blocked users and over-repeated authors.
- Return the page with a cursor.
You do not need ML detail in most interviews. Show that you understand the stages and that ranking runs on a small candidate set, not the entire post table.
Pagination with cursors
Use the last post's ID or timestamp as the cursor. Offset-based pagination breaks when new posts are inserted while the user scrolls, causing duplicates or skips.
Dealing with deletes, edits and privacy
- Delete: mark the post deleted and filter at hydration time; lazily clean feed lists
- Edit: update the post store; feeds hold only IDs, so edits propagate automatically
- Privacy changes: filter by visibility at read time, since precomputed feeds can be stale
Interview tips
State the read-heavy assumption early, present both fan-out strategies with their costs, then land on the hybrid. Interviewers want to hear the celebrity problem unprompted.
Related reading
Frequently asked questions
Was this article useful?
Bring backup into your next round.
Install InterviewPilot, upload your resume, and walk in with structured answers a keystroke away — visible to you and nobody else.
More from the blog
Design a Chat Application: System Design Interview Walkthrough
How to answer the WhatsApp or Messenger system design question: WebSockets, message delivery and ordering, storage, presence, group chats, offline delivery and scaling to millions of connections.
Design a Notification System: System Design Interview Walkthrough
How to design a scalable notification system for push, SMS and email: architecture, queues per channel, retries and idempotency, user preferences, rate limiting and delivery tracking.
Design a Rate Limiter: System Design Interview Walkthrough
A step-by-step answer to the rate limiter system design question: requirements, the four main algorithms and their trade-offs, a distributed Redis design, and the follow-up questions interviewers ask.
Discussion
No comments yet. Been through an interview like this? Your experience could help the next candidate.