Feed System Basics
A feed system (e.g. news feed, timeline) shows the latest content from followed accounts. Common patterns: pull, push, hybrid. This article explains each and when to use it with a reference table.
Overview
- Pull: On feed load, fetch follow list, then pull latest content from those accounts, aggregate and sort. Compute on read; when a celebrity has many followers, each follower read pulls that content → hot spot.
- Push: On post, push to all followers' feed lists (write fan-out). Read is direct; when a celebrity has many followers, write amplification is high.
- Hybrid: Push for normal users, pull for celebrities; or push for recent, pull for older. Balances read and write load.
Example
Example 1: Comparison
| Pattern | Read | Write | Best for |
|---|---|---|---|
| Pull | Aggregate on read; can be slow | Simple write | Few follows, high real-time need |
| Push | Fast; read own list | Write fan-out; hard for celebrities | Few follows, few celebrities |
| Hybrid | Mixed | Mixed | Many celebrities, many followers |
Example 2: Storage
- Feed list: Redis sorted set (score = timestamp), or MongoDB, or dedicated store. Follow graph: graph DB or relation table. Content: object storage + DB metadata.
Example 3: Ordering and pagination
- Reverse chronological; cursor-based pagination (last_id, last_ts) to avoid offset deep pagination.
Example 4: Consistency
- Feed can be eventually consistent; push async after post; user sees it on refresh.
Core Mechanism / Behavior
- Pull: O(follows) reads per feed load; cache follow list and content per author.
- Push: O(followers) writes per post; store precomputed feed per user.
- Hybrid: Push for small fan-out; pull for large (e.g. celebrity threshold).
Key Rules
- Handle celebrities separately: Hybrid or pull-only to avoid write amplification.
- Cold/hot split: Recent feed from cache; older from storage; load on demand.
- Consistency: Feed can be eventual; push async; user sees on refresh.
What's Next
See Pagination, Redis ZSet, Cache Strategy. See High Concurrency Toolkit for high-concurrency design.