How to run a Twitter-style feed design in a 45-minute interview: fan-out on write vs read, the celebrity hybrid, ID-only timeline caches, hydration and cursor pagination.
Published September 21, 2026
This lesson is the interview version of designing a social feed: how to structure the discussion and which deep dives to prepare. The full reference design is the case study Design Twitter / X in this chapter. The class-level design (User, Tweet, Timeline objects) is in Design Twitter/X in the LLD course.
The heart of this problem is one question: when someone opens the app, how do you assemble, in milliseconds, the latest posts from everyone they follow, for hundreds of millions of users, where a few accounts have tens of millions of followers?
client โโถ API gateway โโฌโโถ Tweet service โโโโโโถ Tweet store (by tweet ID) + media on blob storage/CDN
โ โ
โ โโ "tweet created" event โโถ Fan-out workers โโถ Timeline cache (per user: list of tweet IDs)
โ โฒ
โโโถ Social graph service (followers / following)
โ
โโโถ Timeline service: read cached IDs โ merge celebrity tweets โ hydrate tweet bodies โ return page
Fan-out on write (push): when Asha tweets, workers look up her followers and append the tweet ID to each follower's cached timeline.
Fan-out on read (pull): store nothing per user. At read time, fetch recent tweets from everyone the user follows and merge them.
Hybrid (the standard answer):
This hybrid is the key insight interviewers look for. Explain why the threshold exists: it's where push's write amplification becomes more expensive than pull's read-time merge.
followers(user) and following(user), sharded by user ID. Celebrity follower lists are enormous and must be paginated.The timeline cache returns IDs. The service then batch-fetches tweet bodies and author profiles (multi-get from caches) and filters deleted or blocked content. Pagination uses a cursor (the last tweet ID seen), not an offset, so new tweets arriving at the top don't shift pages and cause duplicates.
The tweet is written durably first, then a "tweet created" event goes onto a queue for fan-out. The author sees their own tweet immediately (read-your-writes, via their user timeline). Followers see it seconds later as fan-out completes. Fan-out workers must be idempotent, since appending the same ID twice should be harmless, because queue deliveries can repeat.
Q: What threshold makes an account a "celebrity"? A: It's tuned empirically. It's the follower count where the cost of pushing to every follower (write volume and fan-out delay) exceeds the cost of merging that account's recent tweets at read time for its followers. Thresholds in the tens to hundreds of thousands of followers are typical, and some systems also consider how often the account posts.
Q: How do you handle a user following many celebrities? A: Cap how many celebrity sources are merged per read, cache each celebrity's recent tweet list (it's shared by all their followers, so it's very cacheable), and merge using the time-sortable IDs, a k-way merge of already-sorted lists.
Q: How are deleted tweets removed from millions of timelines? A: Usually not by rewriting every timeline. Mark the tweet deleted in the tweet store, and filter it out during hydration. Stale IDs in timelines are simply skipped, and caches age them out.
Q: How would you add a ranked ("For you") timeline? A: Generate candidates (the cached chronological timeline, celebrity tweets, plus recommendations from outside the follow graph), compute features (engagement, author affinity, recency), score them with a ranking model, then apply diversity and safety rules. The chronological fan-out system becomes the candidate source.
Q: Why use Snowflake-style IDs instead of auto-increment? A: They can be generated independently on many machines without coordination, they sort roughly by time (so ordering and cursor pagination work on the ID itself), and they don't expose exact tweet counts the way sequential IDs do.