Roadmap › System Design — High-Level Design (HLD) from Basics to Case Studies › Module: Case Studies
Lessons in this course (14)
10. Case study — news feed (social timeline)
Advanced★ Must knowLesson 10 of 14
Requirements: post, follow, see a feed of followed users' posts sorted by time; 100M DAU; feed load < 200 ms.
Two ways to build the feed:
| Fan-out on write (push) | Fan-out on read (pull) | |
|---|---|---|
| How | When a user posts, insert the post id into each follower's feed list (Redis) | When a user opens the feed, fetch recent posts from everyone they follow and merge |
| Read cost | Very fast | Slow for users following many |
| Write cost | Huge for celebrities with millions of followers | Cheap |
Hybrid (used by large networks): push for normal users; for celebrities, pull their posts at read time and merge.
text
Client → LB → Post service → Posts DB (sharded by post id) → event "PostCreated" → Fan-out workers → Redis feed lists (per user, last 500 ids)
Client → LB → Feed service → Redis feed list + celebrity posts → hydrate posts from cache/DB → media via CDNExtras: pagination with cursors (not offsets), ranking service, counters for likes eventually consistent, notifications via a queue.