Design a social networking service similar to Twitter. The platform's users will have the capability to compose and share tweets, track the updates of other users, and indicate their appreciation for specific tweets by favoriting them.
Suggested time: 45 minutes
Loading the workspace...
In short: precompute each user's home feed. Store tweets sharded by tweet ID, publish each new tweet to a message queue, and have a feed generator push it into every follower's Redis sorted set ("fan-out on write"). The feed then loads from one cache shard in under 10 ms. Accounts above a follower threshold (1,000 in this design) are the exception: their tweets are kept in a separate list and merged in when the feed is read. Reads outnumber writes about 50 to 1, which is why the work moves to write time.
The building blocks this design relies on, each explained in its own lesson.
Design Instagram (medium)
Design a Platform Like Reddit (medium)
Design Craigslist (easy)
Design TikTok (hard)