A news feed is the central nervous system of any social platform. The core challenge: when a user with 10 million followers posts, how do you get that post into everyone's feed within seconds? This walkthrough covers fan-out strategies, feed ranking, caching at scale, and the hybrid push/pull architecture that powers Twitter and Facebook.
Practice this design with AI
Get coached through each section in a mock interview setting
The hard part of a news feed isn't showing posts in reverse chronological order. It's doing it for 500 million users, each following hundreds of accounts, while keeping latency under 200ms and incorporating a ranking algorithm that makes the feed feel personalized.
Starting with 500M DAU and working through the numbers.
This is a 50:1 read-to-write ratio. Every design decision should optimize for reads.
Three core endpoints. Use cursor-based pagination instead of offset-based - offset pagination breaks when new posts are inserted.
/api/v1/posts``/api/v1/feed?cursor={last_post_id}&limit=20`/api/v1/posts/{post_id}/likes`The feed endpoint is the hot path. Everything else is secondary.

High-Level Architecture
The architecture splits into two distinct paths: the write path (publishing a post) and the read path (fetching a feed).
1. Client sends POST to the API gateway behind a load balancer 2. Post Service validates the request, writes post to the Posts DB (PostgreSQL, sharded by user_id) 3. Post Service publishes a PostCreated event to Kafka 4. Fan-out Service consumes the event, looks up the author's follower list from the Social Graph Service 5. For each follower, the Fan-out Service pushes the post_id into that follower's feed list in Redis
1. Client sends GET /feed to the API gateway 2. Feed Service checks Redis for the user's pre-computed feed (list of post_ids) 3. Feed Service hydrates the post_ids by fetching full post objects from the Post Cache (Redis) or Posts DB 4. Ranking Service scores and reorders the posts based on relevance signals 5. Response returns to the client

Detailed Component Design
Three components deserve a deep look: the Fan-out Service, the Feed Cache, and the Ranking Service.
feed:{user_id}, members = post_ids, scores = timestamps.
Data Model & Database Design
Hybrid storage: PostgreSQL for structured data, Redis for feed cache, S3 for media.
```sql
`Why Snowflake IDs: they're time-sortable (no need for a separate created_at index for ordering), globally unique without coordination, and 8 bytes vs 16 bytes for UUIDs.
feed:{user_id}, Type: Sorted Setpost:{post_id}, Type: Hash
Deep Dives
Deep Dive 1: Fan-Out Strategy - Push vs Pull vs Hybrid
The problem: When a user posts, how do you get that post into every follower's feed? The answer depends on the follower count.
The tradeoff: hybrid adds complexity. You need a "celebrity" flag, a separate read-time merge step, and careful tuning of the follower threshold. But it's the only approach that works at Twitter/Facebook scale.
Deep Dive 2: Feed Ranking and Freshness
The problem: chronological feeds are simple but produce poor engagement. Users miss important posts because they're buried under noise. But ranked feeds can feel stale if you over-optimize for engagement.
The tradeoff: ranked feeds increase engagement 20-30% but generate user complaints about "missing" posts. Provide a "Recent" toggle that switches to chronological ordering.
Deep Dive 3: Cache Invalidation and Consistency
The problem: the feed cache can go stale in multiple ways - a user unfollows someone (stale posts remain), a post is deleted (ghost entries), or engagement counts drift.
Key Trade-offs:
Our AI interviewer will test your understanding with follow-up questions
Start Mock Interview