Back to Academy
system design
News Feed
Design a social media news feed system that aggregates and ranks posts from followed users. The two main approaches are fan-out on write (push model), where a new post is immediately written to all followers' feeds, and fan-out on read (pull model), where the feed is assembled at read time by querying all followed users' posts. Key trade-offs include write amplification versus read latency, storage cost of pre-computed feeds versus CPU cost of on-the-fly assembly, and handling celebrity users with millions of followers. A ranking layer scores posts by recency, engagement, and relevance to personalize the feed.
Use Cases
- •Social media platforms like Twitter/X and Instagram
- •Content aggregation services like Reddit or Hacker News
- •Activity feeds in collaboration tools showing team updates
- •E-commerce product recommendation feeds
Visualization
Implementation
Output
Click "Run Code" to see output...