The System Design Interview: A Step-by-Step Framework
A step-by-step framework for system design interviews: clarifying requirements, estimates, APIs, data models, high-level design, deep dives and trade-offs.
How to design a social news feed: fan-out on write vs read, the celebrity problem, feed caches, ranking, cursor pagination and media delivery.

A news feed shows each user recent posts from the accounts they follow, fast. The central design choice is when to do the work: fan-out on write copies each new post into every follower’s precomputed feed, making reads cheap; fan-out on read assembles the feed when the user opens the app, making writes cheap. Production systems usually combine both, then add ranking, caching and cursor-based pagination on top.
Functional: publish posts (text, images, video), follow accounts, view a feed of followed accounts’ posts, newest or ranked first, with infinite scrolling.
Non-functional: feed loads in a few hundred milliseconds, publishing feels instant, and the system survives traffic spikes. Slight delays in a post appearing in followers’ feeds are acceptable: this is a classic case where eventual consistency is fine.
When someone posts, a background worker looks up their followers and inserts the new post ID at the top of each follower’s feed list.
Run the fan-out asynchronously through a queue so publishing returns immediately; our comparison of Kafka, RabbitMQ and SQS covers the options.
When a user opens the feed, fetch recent posts from each account they follow and merge them.
An account with tens of millions of followers makes fan-out on write explode: one post, tens of millions of inserts. The common answer:
| Approach | Read cost | Write cost | Best for |
|---|---|---|---|
| Fan-out on write | Very low | High for popular authors | Most accounts, most users |
| Fan-out on read | High | Very low | Celebrity accounts, inactive readers |
| Hybrid | Low | Bounded | Large social networks |
Store each feed as a capped list of post IDs, for example the latest 500, in an in-memory store. A sorted set keyed by user, with timestamps or scores, makes inserts and range reads cheap. When a feed is requested:
Keep the post and user caches warm with the patterns in our caching strategies guide; a feed page can touch dozens of objects.
A purely chronological feed is simple and predictable. A ranked feed scores candidate posts on signals such as recency, the viewer’s relationship with the author, predicted interest and content type, often with a machine-learning model. A typical pipeline gathers a few hundred candidates, scores them, then applies rules for diversity and freshness.
Ranking for engagement has side effects on users as well as metrics. It’s worth understanding why endless feeds keep people scrolling before tuning purely for time spent; features like “you’re all caught up” and a chronological option exist for good reasons.
Use cursor-based pagination, not offsets. Return a cursor (for example, the score or ID of the last item served) and fetch the next page after it. Offsets break as new posts arrive: items shift and users see duplicates or gaps.
Likes, comments and shares are write-heavy. Increment counters asynchronously, batch them and accept that displayed counts lag slightly. Showing rounded counts for big numbers (“1.2K likes”) hides small delays, and users rarely need exact values. Notifications for interactions go through a separate pipeline; see our notification system design.
Neither on its own. Fan-out on write gives fast reads for most users; fan-out on read avoids the cost of accounts with huge followings. Large systems use a hybrid.
IDs are small, so millions of feeds fit in memory, and edits or deletions only need changing in one place.
Remove them from the post store and filter them out during hydration. Stale IDs in feed caches then simply disappear from results.
Every article is edited by a human and checked against our editorial policy. Spotted a mistake? Tell us.
A step-by-step framework for system design interviews: clarifying requirements, estimates, APIs, data models, high-level design, deep dives and trade-offs.
A URL shortener system design: requirements, capacity estimates, API, short-code generation, database choice, caching, analytics and scaling trade-offs.
Microservices or a monolith? The real costs and benefits of each, the modular monolith middle ground, and a practical framework for deciding and migrating.