37. Design a News Feed
1
The interview prompt2
37.1 What do you ask first?3
37.2 How big is this, really?4
37.3 What are the doors?5
37.4 What do we store?6
37.5 What does the whole system look like?7
37.6 Fan-out on write or on read?8
37.7 How do you solve the celebrity problem?9
37.8 How does ranking work?10
37.9 How do the feed cache and pagination work?11
37.10 What would you say in the last five minutes?12
Score yourself13
Variations to practise14
Sources15
Code lab37. Design a News Feed
37.3 What are the doors?
3 min read+10 XP
Step 3: API and data model (10 minutes)
POST /v1/posts { "text": "...", "media_ids": ["m_91"] } → 201 { "post_id": "p_123" }
POST /v1/users/{id}/follow → 204
GET /v1/feed?cursor=...&limit=20
returns: { "items": [ { "post_id": "p_123", "author": {...}, "text": "...",
"media": [...], "likes": 41, "created_at": "..." }, ... ],
"next_cursor": "c_8f2..." , "new_posts_available": 3 }
Media is uploaded separately to object storage with presigned URLs (Chapter 11) and served through a CDN (Chapter 26); posts only reference media IDs.