Design Twitter
Problem Design a Twitter-like service: users post tweets, follow others, and read a home timeline of recent tweets from people they follow.
Functional requirements
- Post tweet (text, media reference), follow / unfollow, home timeline (reverse-chronological or ranked), user timeline.
Non-functional requirements
- Read-dominated: timeline reads ~100x tweet writes. Timeline p99 < 200 ms.
- Scale to discuss: 200M DAU, ~5K tweets/sec average (spikes 10x), fan-out to millions of followers for celebrity accounts.
- Availability over strict consistency — a slightly stale timeline is acceptable.
Areas to go deep
- The fan-out strategy for building home timelines at this read:write ratio.
- Timeline cache sizing, eviction, and rebuild for cold users.
- Time-sortable IDs and cursor pagination for ordering.
asked …