Course contentsShow
← System Design
Lesson 1639 of 1,91940. Real-World System: Social Media FeedFree lesson

Hybrid (Pull-Push) Feed Model

Combine push for active users with pull for celebrities or inactive accounts to balance latency and fan-out cost.

Hybrid (Pull-Push) Feed Model

What You'll Learn

You'll learn how to combine push and pull strategies to optimize feed generation for different user types, balancing delivery speed with system cost.


The Core Idea

The Hybrid Model recognizes that not all users are equal: some have millions of followers (celebrities), others are highly active, and some log in rarely. Instead of using pure push or pure pull, you apply the right strategy based on user characteristics:

  • Push for active users: When a regular user posts, fan-out their content immediately to all followers' pre-built feeds (fast reads, manageable fan-out).
  • Pull for celebrities: When a celebrity with 50 million followers posts, don't fan-out to everyone—that's too expensive. Instead, merge their recent posts at read-time when followers request their feeds.
  • Pull for inactive users: Don't maintain pre-built feeds for users who haven't logged in for months; generate their feed on-demand if they return.

How It Works

When a post is created:

  1. Check the author's follower count
  2. If follower count < threshold (e.g., 10,000): Push to all followers' feeds
  3. If follower count ≥ threshold: Store the post, skip fan-out

When a user reads their feed:

  1. Fetch their pre-built feed (from push operations)
  2. Merge in recent posts from celebrities they follow (pull operation)
  3. Sort and rank the combined results

Analogy

Think of a newspaper delivery service: regular subscribers get papers delivered to their doorstep (push), but for special editions or infrequent readers, you just stock them at newsstands where people pick them up themselves (pull).

Key Takeaway: The hybrid model optimizes both latency and cost by pushing to engaged users with manageable fan-out, while pulling for celebrities and inactive accounts to avoid expensive write amplification.