---
title: "[System Design] Hybrid Fan-Out Social Feed: 300M DAU, 100M+ Celebrity Scale, P99 &lt; 500ms"
canonical_url: "https://airsota.com/2026/10/22/system-design-social-feed-timeline-2026-10-22-en/"
date_published: "2026-10-22T16:56:21-07:00"
date_modified: "2026-10-23T14:59:56-07:00"
language: "en-US"
alternate_language_url: "https://airsota.com/2026/10/22/system-design-social-feed-timeline-2026-10-22-zh/"
categories: ["TalentMe (AI 学习与算法架构)", "💻 大厂系统设计与架构 (System Design Pulse)"]
tags: ["architecture", "Distributed Systems", "FAANG Interview", "High Availability", "system-design", "talentme"]
summary: "Balancing write amplification for high-degree nodes against read latency via a hybrid push/pull architecture with Redis Sorted Sets and multi-tier caching."
publisher: "AirSOTA (https://airsota.com)"
---

# [System Design] Hybrid Fan-Out Social Feed: 300M DAU, 100M+ Celebrity Scale, P99 &lt; 500ms

> **Executive Summary**: Balancing write amplification for high-degree nodes against read latency via a hybrid push/pull architecture with Redis Sorted Sets and multi-tier caching.

ARCH CHALLENGE

Social Feed & Timeline Aggregation

    TARGET SCALE

300M DAU, 150M QPS peak reads, 5M QPS writes, P99 < 500ms, 99.99% availability

    TARGET LEVEL

L5 / L6 (Senior / Staff)

    CORE PILLARS

High Availability & Consistency

    

### 🧮 Back-of-the-Envelope Capacity Estimations

    
        Traffic QPS

Reads: 150M QPS (feed refresh + profile views). Writes: 5M QPS (posts, likes, comments). Ratio: 30:1 read-heavy.

        Storage Growth

100 bytes/post * 5M QPS * 86400s * 365d = ~1.6 PB/year raw. With 3x replication and metadata, ~5 PB/year. Retention: 180 days hot, 2 years cold (S3/Glacier).

        Memory / Cache (80/20)

80/20 Pareto: 20% of users (60M) generate 80% of traffic. Cache top 10M active users' timelines in Redis. 10M users * 1000 posts * 1KB = 10TB RAM cluster. Sharded across 100 nodes (100GB/node).

        Bandwidth In/Out

Ingress: 5M QPS * 1KB = 5 GB/s. Egress: 150M QPS * 5KB (feed payload) = 750 GB/s (~6 Tbps). Requires CDN offload for static assets and edge caching.

    

    

### 📐 High-Level Architecture Topology

    
flowchart TD
  C[Client] --> GW[API Gateway]
  GW --> Auth[Auth Service]
  Auth --> FeedSvc[Feed Service]
  FeedSvc --> Redis[Redis Cluster: Sorted Sets]
  FeedSvc --> PostSvc[Post Service]
  PostSvc --> Kafka[Kafka: Event Bus]
  Kafka --> FanOut[Fan-Out Worker Pool]
  FanOut --> Redis
  FanOut --> DB[(PostgreSQL: User Graph)]
  FeedSvc --> Rank[Ranking Service: ML Model]
  Rank --> FeedSvc
  FeedSvc --> GW
    

### 🏛️ Architecture Deep Dive & Component Topology

### Ingestion & Hybrid Fan-Out Strategy

The core challenge is the power-law distribution of followers. A pure push model (fan-out-on-write) causes write amplification for celebrities with 100M+ followers, saturating disk I/O and network. A pure pull model (fan-out-on-read) incurs high latency for users with many friends. We adopt a **Hybrid Model**: Users with  10K followers use Pull (fan-out-on-read). The threshold is dynamic based on cluster load.

### Timeline Storage & Pagination

We use **Redis Sorted Sets** for timelines. Each user has a key `timeline:{user_id}`. Members are `post_id`, scores are `timestamp`. This allows O(log N) insertion and O(1) range queries for pagination. For Pull users, the Feed Service fetches the last N posts from each followed celebrity in parallel, merges them in memory, and sorts by timestamp. This is computationally expensive, so it is cached aggressively.

### Ranking Pipeline

Raw chronological feeds are insufficient. A **Ranking Service** intercepts the merged feed, applies an ML model (e.g., XGBoost or DeepFM) to score posts based on user engagement history, recency, and content type. Features are pre-computed and stored in a feature store (Redis). The ranking step adds ~50ms latency, fitting within the 500ms SLA.

### Cache Invalidation

Cache invalidation is handled via **Event-Driven Invalidation**. When a post is deleted or edited, a Kafka event triggers cache eviction for all affected timelines. For high-fanout users, we use **TTL-based expiration** (e.g., 60s) to avoid cascading failures. Stale-while-revalidate is used for celebrity timelines to handle cache stampedes.

### 💾 Data Models (DDL/Schemas) & API Contracts

### SQL DDL (PostgreSQL)

```
CREATE TABLE users (
  user_id BIGINT PRIMARY KEY,
  username VARCHAR(50) UNIQUE,
  follower_count INT DEFAULT 0,
  following_count INT DEFAULT 0,
  is_celebrity BOOLEAN DEFAULT FALSE
);

CREATE TABLE posts (
  post_id BIGINT PRIMARY KEY,
  author_id BIGINT REFERENCES users(user_id),
  content TEXT,
  created_at TIMESTAMP DEFAULT NOW(),
  likes_count INT DEFAULT 0,
  comments_count INT DEFAULT 0
);

CREATE TABLE follows (
  follower_id BIGINT REFERENCES users(user_id),
  following_id BIGINT REFERENCES users(user_id),
  PRIMARY KEY (follower_id, following_id)
);

CREATE INDEX idx_posts_author ON posts(author_id, created_at DESC);
CREATE INDEX idx_follows_follower ON follows(follower_id);

```

### Redis Schema

```
-- Timeline for user 123
ZADD timeline:123 1698765432 post_456
ZADD timeline:123 1698765431 post_789

-- Fetch last 20 posts
ZRANGE timeline:123 0 19 WITHSCORES

-- Invalidation
DEL timeline:123

```

### gRPC API

```
service FeedService {
  rpc GetFeed(GetFeedRequest) returns (GetFeedResponse);
}

message GetFeedRequest {
  int64 user_id = 1;
  int32 limit = 2; // Default 20
  int64 cursor = 3; // Timestamp for pagination
}

message GetFeedResponse {
  repeated Post posts = 1;
  int64 next_cursor = 2;
  bool has_more = 3;
}

```

### 🛡️ Extreme Failure Scenarios, Stampede Defense & Self-Healing

### Split-Brain & Consistency

In a multi-region setup, split-brain can occur if a celebrity posts in Region A while a follower reads in Region B. We use **Active-Active** with **CRDTs** for follower counts and **Eventual Consistency** for feeds. Reads are served from the local region; writes are replicated asynchronously via Kafka MirrorMaker. Conflict resolution uses Last-Write-Wins (LWW) for metadata and Union for sets.

### Cache Stampede

When a celebrity's timeline cache expires, thousands of concurrent requests can hit the database. We mitigate this with **Request Coalescing**: only one request computes the new timeline; others wait for the result. We also use **Probabilistic Early Expiration** (Jitter) to spread out cache misses.

### Disaster Recovery

If Redis fails, we fall back to **Database-Backed Reads** with aggressive query optimization (pre-computed views). For Kafka, we use **Idempotent Producers** to prevent duplicate fan-outs. Circuit breakers isolate the Ranking Service; if it fails, we serve chronological feeds. Multi-region failover uses **Geo-Redundant DNS** with health checks. RTO < 5min, RPO < 1min.

### Hotspot Mitigation

Celebrity timelines are hotspots. We shard Redis by `user_id % N` and use **Read Replicas** for high-fanout users. For extreme cases (100M+ followers), we use **Approximate Timelines**: only the top 1000 most recent posts are cached; older posts are fetched on demand.

    

### 🎯 Interview Evaluation Rubric: L4/Senior vs L6/Staff Architect

    
        
            L4 / Senior Engineer Baseline

            Proposes a standard microservices architecture with a Postgres database and Redis cache. Implements a simple push model for all users. Uses basic TTL-based cache invalidation. Handles pagination with OFFSET/LIMIT. Does not address the power-law distribution of followers or the write amplification problem for celebrities. Lacks a ranking pipeline.

        

        
            L6 / Staff Architect Differentiators

            Identifies the power-law distribution and proposes a hybrid push/pull model with dynamic thresholds. Uses Redis Sorted Sets for efficient timeline storage and pagination. Implements a ranking pipeline with ML models. Addresses cache stampedes with request coalescing and probabilistic early expiration. Designs for multi-region active-active with CRDTs and eventual consistency. Considers cost optimization by using S3 for cold storage and CDN for static assets. Provides a detailed failure mode analysis with circuit breakers and fallback strategies.

        

    

    🧭 Master FAANG System Design on TalentMe

    Access 69+ production-grade algorithm breakdowns, distributed architecture simulations, and mock interviews.

    [
        🚀 Launch TalentMe Architecture Workbench →
    ](https://talentme.airsota.com)

🛍️ Recommended Gear for This Topic🔥 4 Curated Picks

[](https://www.amazon.com/s?k=CalDigit+TS4+Thunderbolt+4+Dock&tag=airsota2024-20)🔌 Ultimate Dock[CalDigit TS4 Thunderbolt 4 Dock (18 Ports, 98W Power Delivery)](https://www.amazon.com/s?k=CalDigit+TS4+Thunderbolt+4+Dock&tag=airsota2024-20)$$$[View ↗](https://www.amazon.com/s?k=CalDigit+TS4+Thunderbolt+4+Dock&tag=airsota2024-20)

[](https://www.amazon.com/s?k=Herman+Miller+Aeron+Chair&tag=airsota2024-20)💺 Ergonomic Icon[Herman Miller Aeron Ergonomic Office Chair with PostureFit SL](https://www.amazon.com/s?k=Herman+Miller+Aeron+Chair&tag=airsota2024-20)$$$$[View ↗](https://www.amazon.com/s?k=Herman+Miller+Aeron+Chair&tag=airsota2024-20)

[](https://www.amazon.com/s?k=Anker+Prime+240W+GaN+Desktop+Charger&tag=airsota2024-20)⚡ 240W Fast Charge[Anker Prime 240W GaN Desktop Charging Station (4 Ports)](https://www.amazon.com/s?k=Anker+Prime+240W+GaN+Desktop+Charger&tag=airsota2024-20)$140 ~ $180[View ↗](https://www.amazon.com/s?k=Anker+Prime+240W+GaN+Desktop+Charger&tag=airsota2024-20)

[](https://www.amazon.com/s?k=Designing+Data+Intensive+Applications+Martin+Kleppmann&tag=airsota2024-20)📖 Must-Read[Designing Data-Intensive Applications (DDIA) by Martin Kleppmann](https://www.amazon.com/s?k=Designing+Data+Intensive+Applications+Martin+Kleppmann&tag=airsota2024-20)$35 ~ $45[View ↗](https://www.amazon.com/s?k=Designing+Data+Intensive+Applications+Martin+Kleppmann&tag=airsota2024-20)

⚖️ AirSOTA is a participant in the Amazon Services LLC Associates Program. As an Amazon Associate, we earn from qualifying purchases at no extra cost to you.

---
*Source: [AirSOTA Knowledge Matrix](https://airsota.com/2026/10/22/system-design-social-feed-timeline-2026-10-22-en/) · Complete Index: [llms.txt](https://airsota.com/llms.txt)*
