Loading…
Loading…
Functional: post a short text update ("tweet"); follow/unfollow; view a home timeline of tweets from followed accounts; view a single user's own timeline.
Non-functional: timeline reads must be fast at massive read
The core tradeoff (fan-out on write vs. fan-out on read, hybrid for high-follower accounts) is identical to the Instagram Feed problem — see that problem's diagram for the full walkthrough. What's genuinely different for Twitter is the data model, because of retweets and replies.
A retweet should reference the original tweet, not copy its text — otherwise editing/deleting the original (or measuring its real engagement) becomes inconsistent across every copy.
Each tweet stores a parent_tweet_id, forming a tree. Rendering a full thread means walking that tree — for deep threads, this is usually capped and paginated rather than loaded all at once, since a viral thread can have tens of thousands of replies.
Practice this live with an AI interviewer
Starts a System Design mock interview pre-filled with this problem — you can edit the brief before starting.