gcp
System Design
intermediate
Social media content feed

News Feed System

System Design Classic

A news feed system generates personalized content streams for each user by aggregating posts from their connections and ranking them by relevance. The core challenge is the fan-out problem: when a user with millions of followers posts, how do you update millions of feeds efficiently? Recommended for engineers building social platforms where personalized content delivery and fan-out scalability are critical to user engagement.

Data Flow

Feed API
Post Events
Feed Service
Ranking Service
Fan-out Worker
Feed Cache (Memorystore)
Social Graph
Fan-out Topic

Share this architecture with your network

Service Breakdown (8 services)

Other8 services
Feed API
  • Routes API traffic and enforces policies
  • Manages authentication and rate limiting
  • Provides a unified API endpoint
Feed Service
  • Assembles photo feeds from followed accounts
  • Ranks posts by engagement and recency signals
  • Supports infinite scroll with cursor-based pagination
Ranking Service
  • Scores content by engagement, recency, and affinity
  • Uses ML models for personalized feed ordering
  • Balances freshness with predicted user interest
Feed Cache (Memorystore)
  • Caches data in-memory with sub-millisecond latency
  • Supports Redis protocol for broad compatibility
  • Scales vertically without downtime
Social Graph
  • Stores follower and following relationships per user
  • Supports efficient fan-out lookups by follower count
  • Scales with automatic sharding across partitions
Post Events
  • Delivers messages between decoupled services reliably
  • Supports millions of messages per second
  • Guarantees at-least-once delivery to all subscribers
Fan-out Worker
  • Runs event-driven code without servers
  • Scales instantly from zero to peak load
  • Cost-effective for sporadic workloads
Fan-out Topic
  • Delivers messages between decoupled services reliably
  • Supports millions of messages per second
  • Guarantees at-least-once delivery to all subscribers

Scaling Strategy

Feed generation uses a hybrid fan-out: posts from regular users are pre-computed into follower feeds stored in Memorystore, while posts from high-follower users are merged at read time. Pub/Sub handles the real-time event stream for feed updates. The ranking service runs on Cloud Run with ML-based scoring models. Firestore stores the social graph with subcollection patterns for efficient follower lookups.

Related Architectures