📰 Design Social Media Feed — System Design Interview Guide

Hard · Social & Fan-Out

Design the news feed system for a social platform like Twitter/X or Facebook where users see posts from people they follow, in reverse-chronological or ranked order.

Open the interactive Social Media Feed design on PrepGrind → Drag load balancers, caches, databases, and queues onto a canvas, run a live traffic simulation to watch latency and bottlenecks under load, and follow the full interview walkthrough below — free, in your browser.

Functional requirements

Non-functional requirements & scale

Capacity estimation

500M DAU. Average user follows 300 accounts. Each post creation fans out to all followers. Celebrity user with 10M followers = 10M writes on every tweet. Pull model: expensive per feed load. Push model: expensive per post write. Hybrid is required.

Core entities

API design

High-level design

Post created → Fanout Service reads follower list → writes postId to each follower's feed cache (Redis sorted set). On feed load: read from Redis feed cache, hydrate post details. Celebrities use pull-on-read to avoid 10M fan-out writes.

Deep dives

📤 Fan-Out Strategy

Push model: on post create, write postId to every follower's feed cache. Fast reads (O(1)), expensive writes (O(followers)). Pull model: on feed load, fetch posts from all followees. Slow reads, cheap writes. Hybrid: push to regular users (<1000 followers), pull for celebrities at read time. Merge results in Feed Service.

⭐ Celebrity Problem

A celebrity with 10M followers posting = 10M Redis writes in seconds. Solution: skip fan-out for celebrities (mark isHighProfile). On feed load: pull celebrity posts separately from PostDB, merge with pre-built feed cache. Use caching at the celebrity post level (1 cache entry serves 10M users).

📄 Feed Pagination

Use cursor-based pagination (not offset). Cursor = last seen Snowflake postId (timestamp-embedded). Redis sorted set keyed by userId, scored by post timestamp. ZREVRANGEBYSCORE with cursor for O(log N) pagination. Cache up to last 800 feed items per user; older posts fetched from DB.

🏆 Feed Ranking

Chronological: simple sort by createdAt. Ranked: ML model scores based on engagement prediction, recency, relationship closeness. Scoring can be pre-computed offline (batch job updates feed order) or real-time using feature store. Twitter uses a separate ranking service after initial candidate retrieval.

Scaling considerations

What interviewers expect by level

Practice more system design case studies

PrepGrind runs entirely in your browser, free, no installation required. Loading the interactive playground…